我有一个 JSON 对象,比如说:
{
"foo": {
"bar": 1
},
"baz": 2
}
我想将它绑定到一个Java对象,例如:
@JsonIgnoreProperties(ignoreUnknown = true)
public class Foo {
private int bar;
@JsonProperty("baz")
private int baz;
}
我该如何将JSON中foo.bar
的值设置到Java对象Foo
的bar
字段中?
我尝试使用注释@JsonProperty("foo.bar")
来标识这个字段,但是它并不起作用。
Foo
对象的结构,我想上面的解决方案是我能得到的最好的方案了。 - hleinone