Tyron Jung
10/21/2019, 7:09 PMJsonConfiguration(classDiscriminator = "customType")
work only for a particular class? For instance, let’s say I have something like:
@Serializable
data class MyClass(
@Polymorphic
val polymorphicA: PolymorphicA,
@Polymorphic
val polymorphicB: PolymorphicB
)
And I’m serializing/deserializing an instance of MyClass
. I want to serialize/deserialize polymorphicA
using the default classDiscriminator
which is type
. However, I want to serialize/deserialize polymorphicB
using a custom classDiscriminator
, say customType
. I don’t think the steps outlined in https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#a-bit-of-customizing showcase that level of granularity (i.e. if a custom classDiscriminator
is specified, it’s applied to all of MyClass
, which is not what I want).Dominaezzz
10/21/2019, 8:24 PMDominaezzz
10/21/2019, 8:24 PMTyron Jung
10/21/2019, 8:25 PM