-
-
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
valueToTree() doesn't work with WRAP_ROOT_VALUE #4859
Comments
One question, has ur usecase ever worked before? Wondering whether this is a regression or just uncovered case for those features |
I'd have to check as well: I think the idea would be that root wrapping/unwrapping should not be done for case of converting values, including |
@stickfigure Small thing tho, in any case, modifying your reproduction to be decompiled version(plain Java without |
I'm pretty horrified by WRAP_ROOT_VALUE but someone in this company started with it a decade ago and I'm kinda stuck with it. I have no idea if valueToTree() ever worked in this context, I only inherited this codebase recently. In the short run I've subclassed ObjectMapper and overridden return (T)normalNonWrappingObjectMapper.readTree(writeValueAsString(object)); I changed my sample to use It's hard for me to imagine any situation where someone wouldn't expect |
If Lemme trying to read documentation (shared below) see what direction we should be heading. |
Yeah, |
Ok: wrapping is definitely disabled for
|
Ah ha. There is some prior art -> #4047. Funny I didn't even remember this, despite @JooHyukKim and I discussing it just a year ago. :) |
Ah. Actually, this might be working as expected -- there is mismatch wrt expected "Root name": on serialization simple class name ("Thing") is used, and expectation is that same is the case when reading (that is, Root Name expectation is set by simple name, The same thing would occur if explicit
to override expected root name. Or... if you want to keep "Thing" as wrapper, simply leave I am not sure there is anything to be done on Jackson side. |
Strange it felt so new to me 😂. |
In this case, we may close this as |
Agreed. Solution for @stickfigure is, I think, not enabling |
Search before asking
Describe the bug
If you configure these:
Then
mapper.valueToTree()
fails with an exception that looks like this ('Thing' is the type being written to a tree):Version Information
2.17.2
Reproduction
Expected behavior
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: