My api response seems like this
{
"name": "jackson",
"age": 33,
"hobby_list": "[{\"name\":\"soccer\", \"priority\":2}, {\"name\":\"game\", \"priority\":1}, {\"name\":\"reading\", \"priority\":3}]"
}
I want to deserialize hobby_list string value as object.
class Person {
@JsonProperty("name")
private String name;
@JsonProperty("age")
private Integer age;
@JsonProperty("hobby_list")
private List<Hobby> hobbyList;
}
class Hobby(
@JsonProperty("name")
private String name;
@JsonProperty("priority")
private Integer priority;
)
It doesn't work as you know.
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<com.joont.domain.Hobby>` out of VALUE_STRING token
What is the best practice to solve the problem?
Annotation? Configure? Custom deserializer?
JsonNodehobbyListwill be used in many place, I want to implement it common.