-
mkdir <project-dir>
-
cd <project-dir>
-
mkdir lib
-
Download JSON processing library dependencies and put them into the
lib
folder.-
-
jackson-core-2.8.8.jar
-
jackson-annotations-2.8.8.jar
-
jackson-databind-2.8.8.jar
-
-
-
gson-2.8.0.jar
-
-
-
javax.json-1.0.4.jar
-
-
-
json-20160810.jar
-
-
-
Choose a JSON library from the above list and download its related JARs.
-
Start with Jackson or Gson, because
javax.json
andorg.json
doesn’t support direct object serialization/deserialization.
-
-
Import the JARs as dependencies in your IDE project.
-
Create a
Message
class.-
It has an
id
field of typeInteger
-
and a
text
field of typeString
. -
Implement
toString
.
-
-
Create a
Main
class with amain
method which works as follows:-
Deserializes the contents of
single.json
into aMessage
instance.single.json{ "id": 123, "text": "message123" }
-
Prints out the
Message
instance tostdout
. -
Serialalizes the
Message
object to a file calledoutput-single.json
. -
After this it should deserialize the contents of
multiple.json
into aList<Message>
.multiple.json[ {"id": 234, "text": "message234"}, {"id": 345, "text": "message345"}, {"id": 456, "text": "message456"}, ]
-
Prints out the
List<Message>
tostdout
. -
Serialalizes the
List<Message>
object to a file calledoutput-multiple.json
.
-
-
Try to use multiple JSON libraries from the above list.
-
Try to use InputStream and OutputStream objects and their sub-classes.
-
Notifications
You must be signed in to change notification settings - Fork 0
Jakubinyi/Gson_Jackson
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description or website provided.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published