We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Say a bean class only recognize property/field p1, and we have the following JSONs:
p1
{ "p1": ..., // goes to p1 field "p2": ..., // goes to @JsonAnySetter field "p3": ... // goes to @JsonAnySetter field } { "p2": ..., // goes missing ⚠ "p1": ..., // goes to p1 field "p3": ... // goes to @JsonAnySetter field } { "p2": ..., // goes missing ⚠ "p3": ..., // goes missing ⚠ "p1": ... // goes to p1 field }
2.18
public static class Bean { private int b; private int d; @JsonAnySetter private Map<String, ?> any; @JsonCreator public Bean(@JsonProperty("b") int b, @JsonProperty("d") int d) { this.b = b; this.d = d; } } ... String json = "{\"a\":1,\"b\":2,\"c\":3,\"d\":4,\"e\":5,\"f\":6}"; Bean bean = new ObjectMapper().readValue(json, Bean.class); assertEquals(2, bean.b); assertEquals(4, bean.d); // failed with: // org.opentest4j.AssertionFailedError: // Expected :{b=2, c=3, e=5, f=6} // Actual :{e=5, f=6} assertEquals(Map.of("a", 1, "c", 3, "e", 5, "f", 6), bean.any);
No response
@JsonAnySetter
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Search before asking
Describe the bug
Say a bean class only recognize property/field
p1
, and we have the following JSONs:Version Information
2.18
Reproduction
Expected behavior
No response
Additional context
@JsonAnySetter
on constructor parameter.@JsonAnySetter
on Creators #4558 on my local machine.The text was updated successfully, but these errors were encountered: