【发布时间】:2014-06-21 14:18:26
【问题描述】:
我遇到了反序列化问题:
这是我的课:
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...
如果我添加注释,它会通过,但它会将其设置为 null .. 这是我不想要的。
【问题讨论】: