I have a JSON object, say:
{
"foo": {
"bar": 1
},
"baz": 2
}
and I want to bind it into a Java object, like:
@JsonIgnoreProperties(ignoreUnknown = true)
public class Foo {
private int bar;
@JsonProperty("baz")
private int baz;
}
How can I set the value of foo.bar from JSON to the bar field in the Foo Java object?
I’ve tried annotating the field with @JsonProperty("foo.bar"), but it doesn’t work like that.
This ain’t perfect but it’s the most elegant way I could figure out.