Wednesday
14Oct2009
Which is the best Java JSON library?
Wednesday, October 14, 2009 at 8:42AM 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"
Ian Clarke |
3 Comments | in
Java,
Programming
Java,
Programming 

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
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 :-)
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.