nullium21
02/23/2021, 4:57 PM{
"type": "A",
"field": "foo"
}
and such for type B:
{
"type": "B",
"foo": "bar"
}
how to differentiate @Serializable
classes based on the type
field?
the classes I currently have are as follows:
@Serializable
sealed class Message {
@Serializable data class A(field: String, type: String): Message()
@Serializable data class B(foo: String, type: String): Message()
}
Dariusz Kuc
02/23/2021, 4:58 PMclassDiscriminator
Dariusz Kuc
02/23/2021, 4:59 PMDariusz Kuc
02/23/2021, 5:00 PMtype
anywaynullium21
02/23/2021, 5:01 PMnullium21
02/23/2021, 5:34 PM