JSON response
Case 1: only one element exists
{
"Person": {
"first": "foo",
"last": "bar"
}
}
Case 2: more than one element exists (ie) proper array type
{
"Person": [
{
"first": "foo",
"last": "bar"
},
{
"first": "cow",
"last": "pal"
}
]
}
JAXB code which generate above responses which i dont have a control over.
@XmlRootElement
public class PersonContainer {
@XmlElement
List<Person> personList;
}
I use Jackson parser's JAXB feature to unmarshal the JSON to JAXB object. Since there are two types of response is possible , the Jackson parser is not working correctly for Case 1 response.
How do i handle both cases correctly and bind the JSON response?