我有一些JSON我想映射到我的Box对象:
{
"created_date": "2015-11-11",
"generation_date": "2015-11-12T20:35:00+0000",
"values": {
"MORNING": 13,
"EVENING": 18,
"NOON": 446,
"NIGHT": "0.60.0"
},
"id": "12345"
}
Run Code Online (Sandbox Code Playgroud)
我的Box对象看起来像:
public class Box {
@JsonProperty
Map<String, Object> json;
public Box() {
// Blank
}
// Getter and setter for `json` field
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
Box box = null;
// `JSON_STRING` below refers to a string of the above JSON
metricsPacket = new ObjectMapper().readValue(JSON_STRING, Box.class);
Run Code Online (Sandbox Code Playgroud)
我一直收到这个错误:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "created_date" (class com.me.Box), not marked as ignorable (one …