public class TestObj {
public final String name;
public final int age;
@JsonCreator
public TestObj(@JsonProperty("name") String name, @JsonProperty("age") int age)
{
this.name = name;
this.age = age;
}
}
上面的课程被序列化为{“name”:“tt”,“age”:1}
当我试图反序列化时:
f = m.readValue(json, TestObj.class);
我有例外:
org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class TestObj]: can not instantiate from JSON object (need to add/enable type information?)
有任何线索吗?
答案 0 :(得分:1)