tl;dnrUse 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 Articlehttp://goo.gl/0oR3t |
For cross reference, readers will likely find it useful to also have the Gson user guide open in another browser window. (An archive of the Gson user guide as of 2011.06.26 is available at https://sites.google.com/site/programmerbruce/downloads/Gson_User_Guide_2011.06.26.zip.)
This information is based on Gson release 1.7.1 and Jackson release 1.8.2.
The Gson User Guide Walk-through Continued...
Quick Navigation to the Sections of this Review
- 5 Using Gson
- 5.1 Primitives Examples
- 5.2 Object Examples
- 5.3 Nested Classes (including Inner Classes)
- 5.4 Array Examples
- 5.5 Collections Examples
- 5.6 Serializing and Deserializing Generic Types
- 5.7 Serializing and Deserializing Collection with Objects of Arbitrary Types
- 5.8 Built-in Serializers and Deserializers
- 5.9 Custom Serialization and Deserialization
- 5.10 Writing an Instance Creator
- 5.11 Compact Vs. Pretty Printing for JSON Output Format
- 5.12 Null Object Support
- 5.13 Versioning Support
- 5.14 Excluding Fields From Serialization and Deserialization
- 5.15 JSON Field Naming Support
- 5.16 Sharing State Across Custom Serializers and Deserializers
- 5.17 Streaming
Summary of the key differences between Gson and Jackson noted so far
Comparable Features
- COMPARABLE for primitives handling
- COMPARABLE for direct field access handling
- COMPARABLE for default handling of null
- COMPARABLE for synthetic field handling
- COMPARABLE for missing element handling
- COMPARABLE for extra element handling
- COMPARABLE for static nested classes handling
- COMPARABLE for inner classes serialization
- COMPARABLE for basic array handling
- COMPARABLE for basic collections handling
- COMPARABLE for similar support to serialize collections with arbitrary types
- COMPARABLE for basic custom serialization and deserialization support
- COMPARABLE in ability to deserialize with parameterized types
- COMPARABLE in ability to accommodate missing JSON element values
- COMPARABLE for built-in pretty printing capability
- COMPARABLE for global on/off configurability of whether to serialize null references
- COMPARABLE for global configurability to include fields by modifier
- COMPARABLE for simple configurability to include only specified fields for participation in serialization/deserialization
- COMPARABLE for simple configurability of arbitrary logic to exclude fields during serialization and deserialization
- COMPARABLE for ability to use an annotation to specify per-property translation to JSON element names
- COMPARABLE for ability to specify naming strategy translations for all properties
- COMPARABLE for available options to share data between custom serializers and deserializers
- COMPARABLE for ability to read and write JSON one token at a time
Things Gson Does That Jackson Does Not
- +1 Gson for simple unwrapping single-component arrays
- +1 Gson for simple deserialization of inner classes
- +1 Gson for ability to create Java instances without no-argument constructors and without explicit configuration information
- +1 Gson for simple, contextual deserialization with parameterized type information
- +1 Gson for built-in versioning support
- +1 Gson for ability to configure field inclusion by modifiers static, transient, or volatile
- +1 Gson for providing some built-in naming strategies
Things Jackson Does That Gson Does Not
- +1 Jackson for using checked exceptions for errors during JSON parsing and generation
- +1 Jackson for very simple deserialization of any JSON object to a Map, and any JSON array to a List, composed of type-appropriate, standard Java library value objects
- +1 Jackson for providing optional use of getters and setters
- +1 Jackson for anonymous inner classes serialization
- +1 Jackson for significantly more complete data-binding support of multi-dimensional arrays
- +1 Jackson for significantly more complete data-binding support of arbitrarily complex array element types
- +1 Jackson for built-in polymorphic deserialization capability
- +1 Jackson for significantly better support of deserializing to non-generic collections
- +1 Jackson for significantly better support of deserializing to non-generic collections (again)
- +1 Jackson for more built-in serializers and deserializers
- +1 Jackson for allowing easy plug-in of custom pretty printing
- +1 Jackson for greater configurability of null reference serialization
- +1 Jackson for ability to configure field inclusion by default visibility
- +1 Jackson for simple configurability to exclude only specified fields for participation in serialization/deserialization
- +1 Jackson for greater configurability options to include only specified fields for participation in serialization/deserialization
- +1 Jackson for providing a facility to specify different translations for fields versus setter methods versus getter methods
To be continued...
great comparison and code examples proved to be very useful! thanks for doing this :)
ReplyDeleteExcellent study. Thanks!
ReplyDeleteReally good! thanks
ReplyDeleteGreat blog ...thank you
ReplyDeleteReally good blog - very thorough. Thanks for sharing!
ReplyDeleteGreat blog - very thorough. Thanks for sharing!
ReplyDelete