-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
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
@JsonAnySetter
on field ignoring unrecognized properties if they are declared before the last recognized properties in JSON
#4639
Comments
This is clearly a regression and I'm affected by it. Is there a plan to tackle it any time soon, please? |
Not for a while I think, because only recently we released 2.18.0. I wrote #4738 hopefully enough to fix the issue. but even if it gets merged, timing tho. |
The important bit is that there is a fix ready to be merged so that the next release, whenever it happens, will no longer contain the regression. Thanks. |
Thanks we noticed this too at Apache Camel in the camel-salesforce component |
Merged for inclusion in 2.18.1 |
I've just tried 2.18.1 out and sadly it looks like #4738 did not fix this issue for me, @yihtserns. |
@erdi You may need to file a new issue outlining specific remaining problem, with reproduction (sounds like there are multiple problems within same feature). |
That's a fair point, @cowtowncoder. I will need to provide a reproducer as the issue is most likely in the same are but the case is not as simple as the test case added with the fix which is clearly passing. |
Hi @cowtowncoder. I got the same problem with 2.18.1 but instead when using @JsonAnySetter at setter level instead of field level. public class Bean {
final int b;
final int d;
final Map<String,Object> any = new HashMap<>();
@JsonCreator
public Bean(@JsonProperty("b") int b, @JsonProperty("d") int d) {
this.b = b;
this.d = d;
}
@JsonAnySetter
public void setAny(String name, Object value) {
any.put(name, value);
}
}
...
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);
assertEquals(Map.of("a", 1, "c", 3, "e", 5, "f", 6), bean.any);
// failed with:
// Expected :{f=6, e=5, c=3, a=1}
// Actual :{e=5, f=6} |
@bsa01 We don't usually re-open closed issues (too confusing for release notes), so I was to suggest a new issue. But since @JooHyukKim created PR, I think we are ok. |
@JsonAnySetter
on field ignoring unrecognized properties if they are declared before the last recognized properties in JSON
Thanks as the 2.8.1 did not fix our issue in Apache Camel, so good to hear that an additional fix is on the way for 2.8.2 |
we are talking about 2.18 not 2.8. Just to clear things up 😉 @davsclaus |
Oh thanks yeah so many version numbers - Again thanks for all the hard work as OSS maintainer. I know the feeling and how much it takes to care and sit and do this year after year. |
Thank you @davsclaus. |
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: