Skip to content

Jakubinyi/Gson_Jackson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Steps

  1. mkdir <project-dir>

  2. cd <project-dir>

  3. mkdir lib

  4. Download JSON processing library dependencies and put them into the lib folder.

    1. com.fasterxml.jackson

      1. jackson-core-2.8.8.jar

      2. jackson-annotations-2.8.8.jar

      3. jackson-databind-2.8.8.jar

    2. com.google.gson

      1. gson-2.8.0.jar

    3. javax.json

      1. javax.json-1.0.4.jar

    4. org.json

      1. json-20160810.jar

  5. Choose a JSON library from the above list and download its related JARs.

    1. Start with Jackson or Gson, because javax.json and org.json doesn’t support direct object serialization/deserialization.

  6. Import the JARs as dependencies in your IDE project.

  7. Create a Message class.

    1. It has an id field of type Integer

    2. and a text field of type String.

    3. Implement toString.

  8. Create a Main class with a main method which works as follows:

    1. Deserializes the contents of single.json into a Message instance.

      single.json
      {
      	"id": 123,
      	"text": "message123"
      }
    2. Prints out the Message instance to stdout.

    3. Serialalizes the Message object to a file called output-single.json.

    4. After this it should deserialize the contents of multiple.json into a List<Message>.

      multiple.json
      [
      	{"id": 234, "text": "message234"},
      	{"id": 345, "text": "message345"},
      	{"id": 456, "text": "message456"},
      ]
    5. Prints out the List<Message> to stdout.

    6. Serialalizes the List<Message> object to a file called output-multiple.json.

  9. Try to use multiple JSON libraries from the above list.

  10. Try to use InputStream and OutputStream objects and their sub-classes.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages