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
Deserialization with builder ignores @JsonUnwrapped` in field of deserialized object type #3040
Comments
This is intentional: none of target classes annotations are used in any way. To add support for trying to somehow combine annotations from value and builder classes would require significant new effort. The easiest way to think about this is that builder class itself is essentially considered to be THE value being deserialized as far as Jackson is concerned; it is only at the end where "build method" is called and value it returns is returned as the final value. |
When I looked at the
|
It turns out that as of October, Lombok has the |
Thank you for your help here @mjustin -- yes, you are right, Lombok has those useful settings. |
Describe the bug
Deserialization fails when an object uses
@JsonUnwrapped
alongside a builder provided by@JsonDeserialize
, unless that builder's "with" method also uses@JsonUnwrapped
. Jackson appears to be using the builder's value instead of the object's value.I am unsure if this is a bug or intentional, so filing as a bug in case this is not intended behavior.
I am running across this in Lombok, which by default does not transfer the
@JsonUnwrapped
annotation to its generated builder methods. It is very possible to work around this, but in either event, I'd like to know whether this is a bug or working as expected. If the behavior is intended, I will likely follow this up with a bug within Lombok itself if that seems appropriate.Version information
Jackson 2.12.1
To Reproduce
The following unit test reproduces the issue.
Expected behavior
Deserializing an object with
@JsonUnwrapped
should work identically regardless of whether a builder is used or not.The text was updated successfully, but these errors were encountered: