-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or later
Milestone
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
Say a bean class only recognize property/field p1
, and we have the following JSONs:
{
"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
}
Version Information
2.18
Reproduction
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);
Expected behavior
No response
Additional context
- Not reproducible for
@JsonAnySetter
on constructor parameter. - Not reproducible when I tested by reverting Allow
@JsonAnySetter
on Creators #4558 on my local machine.
aleics-lx, jan-leanix, radekoziol, erdi, CyrilleH and 1 more
Metadata
Metadata
Assignees
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or later