lundi 2 mars 2015

How to map a dynamic JSON property to a fixed POJO field



I have some json that i want to parse into pojo



{
"groups": [
{
"g1": [
1,2,5,6,7
]
},
{
"g2": [
2,3,48,79
]
}
]
}


Of course, "g1" and "g1" are the identifiers, so what i would imagine as pojos would be sth like



class Container {
List<Group> groups;
}

class Group {
String id;
List<Integer> values;
}


So it boils down to this question: How to use jackson to map a json-property to the pojo?




Aucun commentaire:

Enregistrer un commentaire