Successfully reported this slideshow.
Your SlideShare is downloading. ×

Comparing JSON Libraries - July 19 2011

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 43 Ad
Advertisement

More Related Content

Slideshows for you (20)

Similar to Comparing JSON Libraries - July 19 2011 (20)

Advertisement

More from sullis (20)

Recently uploaded (20)

Advertisement

Comparing JSON Libraries - July 19 2011

  1. 1. Comparing JSON 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 2011 http://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 JsonWriter Android 1.x Y N Android 2.x Y N Android 3.x Y Y
  23. 23. Benchmarks
  24. 24. Related topics
  25. 25. Native JSON http://blogs.msdn.com/ie/archive/2008/09/10/native-json-in-ie8.aspx http://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

×