Social and professional networking

View Ian Clarke's profile on LinkedIn
Shameless plug

Does your company's revenue depend on being able to predict the future based on past data?  SenseArray may be able to help.

RSS
Links
« A good pretty-printer for Google Gson | Main | A quick thought on "downsizing" strategies »
Wednesday
14Oct2009

Which is the best Java JSON library?

I may not have tried them all, but I've tried quite a few including:

  • The default libraries from json.org
  • Jackson
  • XStream
  • Google Gson
  • JsonMarshaller
  • JSON.simple

I ended up going with Google Gson, the library is simple, efficient, intuitive and flexible.  It allows you to convert JSON objects directly into equivalent Java POJOs[1] and back again, which makes for clean and simple code.  

One annoyance with Gson is that its JSON pretty-printer isn't verbose enough for my tastes, but at the time of writing (Oct 09) this is on their todo list.

[1] "Plain Old Java Object"

Reader Comments (3)

I've been doing some work recently with the Groovy HttpBuilder, which uses JSON-lib. JSON-lib in turn says it's based on the default libraries from json.org you mention above. Have you tried JSON-lib?

--Matt

October 14, 2009 | Unregistered CommenterMatt Passell

I did try JSON-lib, and I don't recall it being too different to the original json.org libraries. I can't remember the details, but I do remember that Google Gson is way better :-)

October 18, 2009 | Unregistered CommenterIan Clarke

One quick note: gson seems simple and flexible, but it doesn't seem very efficient, see [http://www.cowtowncoder.com/blog/archives/2009/09/entry_326.html]. Probably not all that important for casual use cases, but if high throughput is needed it does seem bit slow.

October 28, 2009 | Unregistered CommenterCowtown Coder

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>