Are there any custom JSON to java object parsers to map json properties to Java object attributes through some configuration.
suppose I have class
class Person { String id; String name; String loc;}
My json String is
{name:"xy",id:12, address: {location: "abc"}}
I need map location.address of json to loc property of Person. We need to drive this mapping through config XML or prop file.
EDITED....
I am trying to have grammer or rules defined in property file such as:
address.location = loc
id = id
name = name
This is what I am thinking. Not sure how map complex types such as List, Map, etc
So my code would call a method
Person p = ObjectMapper.map(jsonData,Person.class,configuration)
and actual mapping is done is this way
class ObjectMapper {
public static <T> T map(String jsonData,Class<T> rootType, Map<String,String> rules) {
T object = rootType.newInstance();
// TODO: code to parse json using the rules
//and finally return object
return (T) object;
}
This is what I am planning to do. Any help is appreciated. Thanks in Advance.