Your SlideShare is downloading. ×
0
ComparingJSON libraries        Sean Sullivan  Portland Java User Group        July 19, 2011
JavaScript Object Notation
{                         “hello” : “world”,                         “count” : 1                     }pentagon   hexagon  ...
JSON is a data interchange format
{    “name” : “Mock Crest Tavern”,    “tags” : [ “music”, “beer”, “tots” ],    “location” :    {        “city” : “Portland...
JSON• based on a subset of the JavaScript  programming language• text format• language independent
RFC 4627
How is JSON useful to Java developers?
Web Services
“In the first version of our API, data was available      in XML, with JSON support added largely as an      afterthought. ...
JSON libraries• json.org library• Google GSON• Jackson• lift-json
http://json.org/javadoc
import org.json.*;JSONObject obj = new JSONObject();obj.put(“Hello”, “World”);obj.put(“count”, 1);String json = obj.toStri...
http://jackson.codehaus.org/
import org.codehaus.jackson.*;import org.codehaus.jackson.map.*;ObjectMapper mapper = new ObjectMapper();String json = map...
http://code.google.com/p/google-gson/
import com.google.gson.*;GsonBuilder builder = new GsonBuilder();Gson gson = builder.create();String json = gson.toJson(fo...
Jackson vs GSON• GSON serializes all non-transient non-  static fields. GSON accesses fields directly  with Java’s Reflection...
JSON and Scala
lift-json
JSON and Android
JsonReader,              json.org                         JsonWriterAndroid 1.x      Y           NAndroid 2.x      Y      ...
Benchmarks
Related topics
Native JSONhttp://blogs.msdn.com/ie/archive/2008/09/10/native-json-in-ie8.aspxhttp://blog.mozilla.com/webdev/2009/02/12/na...
For more information• http://www.json.org• http://en.wikipedia.org/wiki/JSON
Thank you
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
Upcoming SlideShare
Loading in...5
×

Comparing JSON Libraries - July 19 2011

11,931

Published on

Comparing JSON Lib

Published in: Technology, Education
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
11,931
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
104
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Transcript of "Comparing JSON Libraries - July 19 2011"

  1. 1. ComparingJSON libraries Sean Sullivan Portland Java User Group July 19, 2011
  2. 2. JavaScript Object Notation
  3. 3. { “hello” : “world”, “count” : 1 }pentagon hexagon json
  4. 4. JSON is a data interchange format
  5. 5. { “name” : “Mock Crest Tavern”, “tags” : [ “music”, “beer”, “tots” ], “location” : { “city” : “Portland”, “state” : “Oregon” }}
  6. 6. JSON• based on a subset of the JavaScript programming language• text format• language independent
  7. 7. RFC 4627
  8. 8. How is JSON useful to Java developers?
  9. 9. Web Services
  10. 10. “In the first version of our API, data was available in XML, with JSON support added largely as an afterthought. XML as a means for delivering developer-friendly data hasn’t aged well. Seeing the growing inclination of developers and API makers alike towards JSON, we’ve decided to eliminate XML support and put the energy spent there into getting our JSON implementation just right.” July 2011http://engineering.tumblr.com/post/7541361718/introducing-tumblrs-new-api
  11. 11. JSON libraries• json.org library• Google GSON• Jackson• lift-json
  12. 12. http://json.org/javadoc
  13. 13. import org.json.*;JSONObject obj = new JSONObject();obj.put(“Hello”, “World”);obj.put(“count”, 1);String json = obj.toString();
  14. 14. http://jackson.codehaus.org/
  15. 15. import org.codehaus.jackson.*;import org.codehaus.jackson.map.*;ObjectMapper mapper = new ObjectMapper();String json = mapper.writeValueAsString(foo);Foo foo2 = mapper.readValue(json, Foo.class);
  16. 16. http://code.google.com/p/google-gson/
  17. 17. import com.google.gson.*;GsonBuilder builder = new GsonBuilder();Gson gson = builder.create();String json = gson.toJson(foo);Foo foo2 = gson.fromJson(json, Foo.class);
  18. 18. Jackson vs GSON• GSON serializes all non-transient non- static fields. GSON accesses fields directly with Java’s Reflection API• Jackson uses JavaBean methods (setter methods / getter methods)
  19. 19. JSON and Scala
  20. 20. lift-json
  21. 21. JSON and Android
  22. 22. JsonReader, json.org JsonWriterAndroid 1.x Y NAndroid 2.x Y NAndroid 3.x Y Y
  23. 23. Benchmarks
  24. 24. Related topics
  25. 25. Native JSONhttp://blogs.msdn.com/ie/archive/2008/09/10/native-json-in-ie8.aspxhttp://blog.mozilla.com/webdev/2009/02/12/native-json-in-firefox-31/
  26. 26. For more information• http://www.json.org• http://en.wikipedia.org/wiki/JSON
  27. 27. Thank you
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×