Showing posts with label json. Show all posts
Showing posts with label json. Show all posts

2011-07-11

Gson v Jackson - Part 6

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 5 of this short series of articles ended with section 5.17 of the Gson user guide, "Streaming". (Sections 6 and 7 will not be reviewed.) This sixth part includes a summary of the key differences between Gson and Jackson noted so far, along with a table of contents listing for easy navigation to the various sections of this review.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/0oR3t

2011-07-10

Gson v Jackson - Part 5

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 4 of this short series of articles ended with section 5.14.3 of the Gson user guide, "User Defined Exclusion Strategies". This fifth part continues with section 5.15 on "JSON Field Naming Support", and ends with section 5.17 on "Streaming", which is the end of the Gson user guide. Part 6 will include a summary of the key differences between Gson and Jackson noted so far, along with a table of contents listing for easy navigation to the various sections of this review.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/fWihj

2011-07-03

Gson v Jackson - Part 4

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 3 of this short series of articles ended with section 5.10.1 of the Gson user guide, "InstanceCreator for a Parameterized Type". This fourth part continues with section 5.11 on "Compact Vs. Pretty Printing for JSON Output Format", and ends with section 5.14.3 on "User Defined Exclusion Strategies". Part 5 will continue with section 5.15 on "JSON Field Naming Support".
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/RpFIE

2011-07-02

Gson v Jackson - Part 3

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 2 of this short series of articles ended with section 5.7 of the Gson user guide, titled "Serializing and Deserializing Collection with Objects of Arbitrary Types". This third part continues with section 5.8 on "Built-in Serializers and Deserializers", and ends with section 5.10.1 on "InstanceCreator for a Parameterized Type". Part 4 will continue with section 5.11 on "Compact Vs. Pretty Printing for JSON Output Format".
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/HsIea

2011-06-27

Gson v Jackson - Part 2

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 1 of this short series of articles ended with section 5.3 of the Gson user guide, titled "Nested Classes (including Inner Classes)". This second part continues with section 5.4 on "Array Examples", and ends with section 5.7 on "Serializing and Deserializing Collection with Objects of Arbitrary Types". Part 3 will continue with section 5.8 on "Built-in Serializers and Deserializers".
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/qkceb

2011-06-25

Gson v Jackson - Part 1

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

What is this post?

Is this yet another JSON-to/from-Java API comparison? Yes, it is. It's the most comprehensive comparison of using Gson versus Jackson for common JSON-to/from-Java tasks known. The sections below walk through each section of the Gson user guide, demonstrating similar implementations with Jackson. API features beyond what is described in the Gson user guide are then reviewed.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/YuYhx

2011-05-25

Deserialize JSON with Jackson into Polymorphic Types - A Complete Example

Jackson API Versions Note

The following code examples were written using Jackson 1.7.x or 1.8.x. They probably work as-is with Jackson 1.9.x, but Jackson 2.0 introduced API changes significant enough that this code does not compile with it. On initial review, it appears that package names changed, and at least one method signature changed or was moved or was renamed or no longer exists. In the near future, I may post updated code examples that use Jackson 2.x.

tl;dnr

Skip to the fourth, fifth, and sixth examples.

Why This Post Exists

While recently answering a question on StackOverflow.com about deserialization of JSON into polymorhpic types in Java, I couldn't find a simple and complete example using Jackson. At the time of this writing, the official documentation on the subject describes aspects of how to do this, but it doesn't have a full example. Searching other resources also didn't turn up any complete examples.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/nVKBZ

Following are deserialization examples with Jackson that build up to a complete example of populating a polymorphic data structure in Java. The first three examples do not involve Polymorphism. Polymorphism is introduced in the fourth example.