Coder Social home page Coder Social logo

io.pr2's Introduction

IO. Practice Task 2

1. Json Output Stream

Your task is to create implementation IJsonOutputStream interface that should be named as JsonOutputStream and should also be a Filtering stream - so you need to extend FilterOutputStream also.

The only method that should be implemented is writeJson that consumes object of type JsonType and performs write operation.

To show usage of your stream you need to implement all reasonable JSON related data types:

  • Json String
  • Json Number
  • Json Array
  • Json Object
  • Json Boolean

All this types should implement JsonType interface.

Json String

This data type should be an immutable data type that is actually just wrapper above regular java String.

Strings in JSON format are just quoted sequence of characters:

"I need to use Quotes(\")"

Json Number

This data type should be an immutable data type that is actually just wrapper above regular java Number.

Numbers in JSON format are represented by their values.

Json Array

This data type should be an immutable data type that is actually just wrapper above java Collection of other JsonType objects.

Arrays in JSON format are represented as in example below:

[1,2,"3",4,{"property":"value"},[1,2]] 

So, you see, that there are no restrictions for data types that are actually in the array.

Json Object

This data type should be an immutable data type that is actually just wrapper above java Map of String keys and JsonType values.

Objects in JSON format have following representation:

{
    "string": "value",
    "list": [1, 2, 3, "String"],
    "anotherEmptyObject": {},
    "anotherObject": {
    	"key": "value"
    },
    "boolean": true,
    "null": null,
    "integer": 1,
    "double": 2.2
}

Json Boolean

This data type should be an immutable data type that is actually just wrapper above regular java Boolean.

Boolean should be represented as true or false

Demo

You should create Demo class and show usage of your implementation.

In your demo you need to create complex JsonObject and save it to the file called demo.json.

You should also demonstrate usage of your stream with System.out stream.

jUnit test

You should create jUnit tests for all your JSON types and JsonOutputStream.

io.pr2's People

Contributors

xsavikx avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.