What is the best library out there for parsing JSON on android. I know the Android framework has a JSON library built in, and I've heard of GSON. But I'm wondering if anyone has compared the various JSON options on android and come up with a justification for choosing one over the other. I'm thinking of performance and usability as the main criteria.
The tally for fastest library on number of files won is: GSON – 14. JSONP – 5. Jackson – 1.
GSON can use the Object definition to directly create an object of the desired type. While JSONObject needs to be parsed manually.
JSON (JavaScript Object Notation, pronounced /ˈdʒeɪsən/; also /ˈdʒeɪˌsɒn/) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values).
While there is a handful of Java-to/from-JSON APIs that provide for easy (basic) binding between JSON and an arbitrary Java data structure, Jackson and Gson are by far the most sophisticated (capable) and feature-rich options.
Back in July (2011), I posted a multi-part series on my blog comparing using Gson versus Jackson, stepping through features as they were organized in the Gson User Guide, including examples of comparable implementations in Jackson (and of implementations in Gson, where the Gson User Guide was incomplete or broken).
The sixth part of the series provides easy navigation links for the comparison, as well as a summary comparison listing. http://programmerbruce.blogspot.com/2011/07/gson-v-jackson-part-6.html
This is the most comprehensive comparison of using Gson versus Jackson for common JSON-to/from-Java tasks known.
As mentioned, performance comparisons of various Java-to/from-JSON APIs are available at https://github.com/eishay/jvm-serializers/wiki. The current release of Gson (2.0) shows to be about 16 times slower than the current release of Jackson (1.9.2) at serializing and deserializing a 500 byte JSON structure, using very comparable implementation efforts (just one or two lines of code).
Martin Adamek posted some performance results of various APIs running on Android at http://martinadamek.com/2011/01/31/comparison-of-json-parsers-performance-on-android/ and http://martinadamek.com/2011/02/04/json-parsers-performance-on-android-with-warmup-and-multiple-iterations/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With