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. Edit (Sep 2011): I created my own JSON pretty-printer that works with Gson – see here for more information.

[1] “Plain Old Java Object”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>