classDiscriminator
Name of the class descriptor property for polymorphic serialization. type
by default.
Note that if your class has any serial names that are equal to classDiscriminator (e.g., @Serializable class Foo(val type: String)
), an IllegalArgumentException will be thrown from Json {}
builder. You can disable this check and class discriminator inclusion with ClassDiscriminatorMode.NONE, but kotlinx.serialization will not be able to deserialize such data back.