Just like in this question, I want to deserialize JSON with a root element using @JsonRootName
. But in my case, the value of the root field is an array with exactly one object instead of just an object.
So instead of this
{
"user":
{
"name":"Sam Smith",
"age":1
}
}
I have this
{
"user":[
{
"name":"Sam Smith",
"age":1
}
]}
I cannot simply use
@JsonRootNode(value="user")
public class User {
public String name;
public Integer age;
}
because that would produce a JsonMappingException: Can not deserialize instance of User out of START_ARRAY token
.
Is there a way to tell jackson to ignore the array and just look at the object?