Comparing JSON Libraries - July 19 2011
Upcoming SlideShare
Loading in...5
×
 

Comparing JSON Libraries - July 19 2011

on

  • 12,247 views

Comparing JSON Lib

Comparing JSON Lib

Statistics

Views

Total Views
12,247
Views on SlideShare
12,243
Embed Views
4

Actions

Likes
5
Downloads
93
Comments
0

3 Embeds 4

https://twitter.com 2
http://twitter.com 1
https://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Comparing JSON Libraries - July 19 2011 Comparing JSON Libraries - July 19 2011 Presentation Transcript

  • ComparingJSON libraries Sean Sullivan Portland Java User Group July 19, 2011
  • JavaScript Object Notation
  • { “hello” : “world”, “count” : 1 }pentagon hexagon json
  • JSON is a data interchange format
  • { “name” : “Mock Crest Tavern”, “tags” : [ “music”, “beer”, “tots” ], “location” : { “city” : “Portland”, “state” : “Oregon” }}
  • 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. 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
  • 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.toString();
  • http://jackson.codehaus.org/
  • 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);
  • http://code.google.com/p/google-gson/
  • import com.google.gson.*;GsonBuilder builder = new GsonBuilder();Gson gson = builder.create();String json = gson.toJson(foo);Foo foo2 = gson.fromJson(json, Foo.class);
  • 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)
  • JSON and Scala
  • lift-json
  • JSON and Android
  • JsonReader, json.org JsonWriterAndroid 1.x Y NAndroid 2.x Y NAndroid 3.x Y 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/native-json-in-firefox-31/
  • For more information• http://www.json.org• http://en.wikipedia.org/wiki/JSON
  • Thank you