ankushg
08/27/2019, 9:32 PMdynamic into a sealed (polymorphic) class using DynamicObjectParser, use a different mechanism than the normal classDiscriminator=SerialName to determine which concrete type is selected?
For context, I'm consuming dynamic json objects from an external source (which will be very very hard to change to provide a classDiscriminator along with everything). They've got typescript definitions such as:
type AttributeContentType =
| {
word: String;
}
| {
definition: String;
};
I've represented this in Kotlin as:
sealed class AttributeContentType
data class WordAttributeContent(val word: String) : AttributeContentType()
data class DefinitionAttributeContent(val definition: String) : AttributeContentType()
In the above case, I'd want something like js("""{ word: "foo" }""") to be deserialized into a WordAttributeContent by (somehow) seeing that it has the word field.