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
Deserialise JSON array where an element is polymorphic #4277
Comments
Actualy realised by example might be slightly wrong as im setting |
Would be helpful if the reproduction had failing assertions against the output JSON string or values, instead of |
Yeah, use of +1 for actual unit test -- test code that requires manual inspection of textual output is not automatable, and it typically ambiguous wrt meaning ("what is it supposed to be again?"). |
Ok think I understand this issue, i'm basically in an unsupported case, POJO-as-array where one polymorphic elements type is declared in another element. I'm thinking a better solution would be needed, something like an |
@jamesmudd Yes, at least currently this is unsupported. I am not 100% sure it couldn't be solved, fwtw, but the whole Still, if you or anyone else wants to try to figure it out (and has time & interest), I'd be happy to help with PR. I don't have time to drive it, but do my best to try to help. |
Search before asking
Describe the bug
I also rasied this as a SO question so far with no response but I believe it might be a bug.
When I try to deserialise a JSON array with an element containig the type of another element the polymorphic type doesn't seem to be handled correcly. The code can work if you change to use
JsonTypeInfo.Id.DEDUCTION
again suggesting the issue is in the type selection.I beleive the source of the issue here is somehow the combination of
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
withJsonTypeInfo.As.EXTERNAL_PROPERTY
and a polymorphic array ellement.Version Information
2.15.3
Reproduction
Expected behavior
Should deserialise correctly (and with more possible types)
Additional context
This example is kind of an extension of
JsonTypeInfo.As.WRAPPER_ARRAY
where the array also includes other elements in this exampleuniqueId
.The text was updated successfully, but these errors were encountered: