给定以下 JSON
{
"obj" : {
"f1" : "blah",
"f2" : "blah",
"f3" : [{"z1" : "blah", "arr" : [{"m1" : "blah", "m2" : "blah"}]}]
}
}
我已经厌倦了使用@JsonProperty
and@JsonCreator
来映射"m1"
和"m2"
值,但没有运气。
随着@JsonCreator public Card(Map<String,Object> props) { }
我得到以下错误:
Argument #0 of constructor [constructor for MyObj$Obj$Card, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator()}] has no property name annotation; must have name when multiple-paramater constructor annotated as Creator
随着@JsonCreator public Card(@JsonProperty("m1") String m1, @JsonProperty("m2") String m2,){}
我得到以下错误:
Argument #0 of constructor [constructor for MyObj$Obj$Card, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator()}] has no property name annotation; must have name when multiple-paramater constructor annotated as Creator
如何"arr"
使用 Jackson 注释映射字段?谢谢。
更新
我也尝试加入@JsonProperty("arr") private Card[] cards;
课堂f3
,但也无济于事。
更新 2
我在上面的更新中更改了数组类型,现在我没有收到错误,但它的行为不像我希望的那样(我想处理映射)。
有没有机会以一种我可以纠正的方式解释错误。