com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field
我遇到了一个反序列化问题:
这是我的类:
public class Response {
private Object ResObj;
private int ResInt;
public Object getResObj() {
return ResObj;
}
public int getResInt() {
return ResInt;
}
}
我想反序列化的JSON是:
{"ResObj":{"ClientNum":"12345","ServerNum":"78945","IdNum":"020252"},"ResInt":0}
我得到这个例外:
Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ResObj" , not marked as ignorable (0 known properties: ])
at [Source: java.io.StringReader@1f758500; line: 1, column: 20] (through reference chain: ["ResObj"])
我不想添加:
@JsonIgnoreProperties(ignoreUnknown = true)
因为我想得到ResObj...
如果我添加注释,它会通过,但它会将其设置为空值。我不想要。