Support for polymorphic deserializers base on tag name
See original GitHub issueSuppose we have a sealed class hierarchy like this:
sealed class S
@SerialName("a")
class A: Parent()
@SerialName("b")
class b: Parent()
class Holder{
val children = ArrayList<@ContextualSerialization S>()
}
Then we create an array of S
and pass it to serializer via `ContextSerializer, obtaining something like
<Holder>
<a>...</a>
<b>...</b>
</Holder>
Currently deserializer tries to interpret those tags as fields. It is important to be able to somehow tell it that those are parts of the list.
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Deserialize JSON with Jackson into Polymorphic Types
A simple way to enable polymorphic serialization / deserialization via Jackson library is to globally configure the Jackson object mapper ( ...
Read more >Polymorphic deserialization based on root tag #537
Hello! I am not sure if this is a help or a feature request. I scoured google/SO trying to dynamically select target class...
Read more >Polymorphic deserialization with Jackson and no annotations
Deserialization with no annotation First thing to do is to create a custom Jackson deserializer and implement the logic of deserialization. To ...
Read more >Polymorphism and Inheritance with Jackson
This article describes how to serialize and deserialize objects by their interface, as well as Polymorphic Tree Structured object instances. ...
Read more >Migrate from Newtonsoft.Json to System.Text.Json - .NET
Polymorphic deserialization. Newtonsoft.Json has a TypeNameHandling setting that adds type-name metadata to the JSON while serializing. It uses ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems to be working now!
I’ve added some documentation to the README. I’ll keep
@XmlPolyChildren
as is for now. The main use case with the new autoPolymorphism is where it is necessary to specify the use tag name at use site (not on the type - something incompatible with normal use of XmlSchema). I’m not sure that class arrays are supported by the serialization plugin yet.