-
Notifications
You must be signed in to change notification settings - Fork 624
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
Invalid json: Type descriminator is output in json array literals when adding unrelated polymophic serialized property to class #2164
Comments
I've just realized that you're using custom transformers, and they're likely the problem here: polymorphism should be able to add Why do you need to transform polymorphic objects into primitives? Do you realize that you won't be able to deserialize them back, as type info is lost? |
Somewhat related: #2049 (as value classes also have incorrect polymorphic type discriminator) |
Sorry I missed this your question here. Yes we know but would like to be able to! What we are trying to do is similar to content-based-polymorphic-deserialization except that we want it to apply to a single json value that may be either a string or a number as you can see in the example. In our system this Obviously it would be nice to have first class support for |
I think it's possible to use |
@sandwwraith We just ran into this on latest ( Output example:
The Edit: The bug is present on |
…serialization for JsonTransformingSerializer If JsonTransformingSerializer is used as a serializer for the descendant of a polymorphic class, then we do not know how to add a type discriminator to the returned result of a primitive or array type. Since there is no general solution to this problem on the library side, the user must take care of the correct processing of such types and, possibly, manually implement polymorphism. Resolves #2164
…serialization for JsonTransformingSerializer If JsonTransformingSerializer is used as a serializer for the descendant of a polymorphic class, then we do not know how to add a type discriminator to the returned result of a primitive or array type. Since there is no general solution to this problem on the library side, the user must take care of the correct processing of such types and, possibly, manually implement polymorphism. Resolves #2164
…erializer with polymorphic serialization If JsonTransformingSerializer is used as a serializer for the descendant of a polymorphic class, then we do not know how to add a type discriminator to the returned result of a primitive or array type. Since there is no general solution to this problem on the library side, the user must take care of the correct processing of such types and, possibly, manually implement polymorphism. Resolves #2164
Describe the bug
This is output in the following
"tags":["type":"kotlin.collections.ArrayList","2323"]
Expected behavior
If I remove the
stringOrInt
property this is output:It is not visible in my reduced case here but in my real case the equivalent of
Foo
instances also got a type descriminator in the json even though it should not be needed.To Reproduce
Environment
The text was updated successfully, but these errors were encountered: