I have a JSON structure that looks like this:
{"data": [{"mykey": "someval"}, {"mykey": "someotherval"}], "foo": "bar"}
I also have
public MyClass {
public String mykey;
}
Now I would like to deserialize the content of "data"
of my JSON into a List<MyClass>
using Jackson, so I have this code:
ObjectMapper mapper = new ObjectMapper();
List<MyClass> l = (List<MyClass>) mapper.readerFor(new TypeReference<List<MyClass>>(){}).
withRootName("data").readValue(myJSONString);
However this gives me an exception:
com.fasterxml.jackson.databind.JsonMappingException: Unexpected token (FIELD_NAME),
expected END_OBJECT: Current token not END_OBJECT (to match wrapper object with root name
'data'), but FIELD_NAME
Anyone know what I need to do to get this parsed?