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

java, json, pojo, xml

Solution

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.

Problem

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?

Original source