-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ObjectMapper.convertValue to Map leads to unexpected Map for type configured with @JsonSubTypes and @JsonValue #5035
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
Comments
I suspect there seems to be misunderstanding of how Regardless, can you try separately serialize - deserialize combo and see if it works? --if so, should look into convertValue implementation |
Yes, and trying to use I am not sure I understand intended use case here. @blacelle What exactly are you trying to do here? |
The actual fonctional case is the following:
As as Jackson user, I felt it worked this way, but I supposed the implementation might be different. The following testCase confirms something is unexpected (to me) with
If I remove When I switch |
What really might cause problems is I am not sure we can ever fully support that. (I am also not sure about |
@cowtowncoder I switched from If (i.e. I do not want to bring burden, just reporting what looks suspicious issues, with fully reproducible cases, to help increasing quality in this already great library (!).) |
Yes, try reading for more documenations, references such as stack overflows and such 👍🏼 |
Are you suggesting people should not open bug-report? The behavior looks weird (i.e. unexpected & inconsistent) enough to deserve being reported to the development team, even more as it followed some change suggested by development team.
What's missing here to get this ticket considered as a bug report?
The message here is: is this bug looks too complicated, or irrelevant as too edgy, just close this ; this comes from following a recommendation from development team, but given some of your feedbacks, I understand it may be pop more issues the solving ones.
I also understand this can be workarounded by not using |
Oh no, not quite. Maybe I gave wrong idea @blacelle
I thought you considered yourself not very experienced was asking for feedback? So I gave feedback of how to get more experience around Always welcome for reports |
I meant, not being experienced with The suggestion to use was in #5030 (comment), but I suppose this @cowtowncoder missed @cowtowncoder I let you close this if this confirmed as not relevant. I may dig into it, out of curiosity, but can not say if I would do so earlier or later. |
@blacelle Just to re-iterate: filing bugs for suspicious things is always welcome! I think we should leave this open for now. I wish I had time to dig into it, but right now I don't (wrt Jackson 3.0 work in particular). And yes, combination of I hope this helps explain things bit better. |
Note for myself (@cowtowncoder Got a syntetical question for you at the bottom): In the faulty case, If
block and gets into
which seems not to write the type in the end. We get into some specific
One may think this ticket is about
In the
The output array format relates with @cowtowncoder In
Why does the lack of a valueSerializaer leads to a different way to serialize the type? I mean, naively, I would expect the code to look like:
This different of behavior explains why a |
I concur that does seem like it should be the way you describe. I do not remember background to this decision. If you change it, does some existing unit test fail? If not and it helps, we could definitely considering changing code. On The reason why @blacelle Not sure how much this helps: you have done exemplary work digging through the code, kudos! |
Search before asking
Describe the bug
Given some type wrapping a
String
property, with a deserialization startegy configured through@JsonSubTypes
and@JsonValue
,ObjectMapper.convertToMap
leads to an unexpected output Map.Instead of producing a Map with the
@JsonValue
as value, we receive a List of 2 elements: the name as defined by@JsonSubTypes
and the@JsonValue
attribute.If the
@JsonValue
attribute is an Object (instead of aString
), we receive the expected value (not embedded in a List.Follows some analysis for an unrelated issue in #5030
Version Information
2.18.2
Reproduction
Expected behavior
Always receive the
@JsonValue
attribute as Map value.Additional context
No response
The text was updated successfully, but these errors were encountered: