I am looking for a Java library to convert my domain objects into a flattened JSON
eg.
public class Person {
String name
Address homeAddress
}
public class Address {
String street
String zip
}
JSON: {name:'John', homeAddress_street: '123 Street', homeAddress_zip: 'xxxxx'}
I've looked into XStream, Eclipse MOXy, FlexJSON, JSON-lib & gson
My goal is to get rid of my json wrapper classes and minimize code. I would like to have a general service that would take any domain model class I have and get a json representation without having to write xml descriptors or any custom converters for each type of model. A depth of 1 level deep is sufficient for my models. I have not found an easy generic solution using annotations or built in functionality in the above libraries but I have probably overlooked them. Is there a non intrusive library that can do this? or maybe one that I've listed? I'm using Hibernate so the library must be able to deal with CGLib Proxies