Is there a library to convert Java POJOs to and from JSON and XML?

Darren Hague picture Darren Hague · Mar 18, 2009 · Viewed 38.1k times · Source

I have an object graph that I would like to convert to and from JSON and XML, for the purposes of creating a REST-style API. It strikes me that someone must have done this already, but a quick search using Google and Stack Overflow reveals nothing.

Does anyone know of a suitable (Apache or equivalent license preferred) library to do this?

Answer

NimChimpsky picture NimChimpsky · Aug 15, 2011

GSON from google : http://code.google.com/p/google-gson/,

or

Jackson the library used in spring :https://github.com/FasterXML/jackson

and I would concur with others suggesting jaxb for XML to pojo, well supported lots of tools : its the standard.