question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for polymorphic deserializers base on tag name

See original GitHub issue

Suppose 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:closed
  • Created 4 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
altavircommented, Jul 16, 2019

Seems to be working now!

0reactions
pdvriezecommented, Jul 16, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found