Moroa Matshubeni
04/24/2024, 7:05 PMSealed class cannot be serialized as base class because it has property name that conflicts with JSON class discriminator 'type'. You can either change class discriminator in JsonConfiguration, rename property with @SerialName annotation or fall back to array polymorphism
Please note that changing the class discriminator causing the API to reject the payload.
@Serializable
sealed class Message { abstract type: String }
@Serializable
sealed class MessageHeader { abstract type: String }
@Serializable
data class VideoHeader( override val type: String, val video: Media ): MessageHeader
@Serializable
data class TextMessage( override val type: String, text: String, header: MessageHeader ): Message
hho
04/24/2024, 8:45 PMtype
field in the JSON, you can remove the property and set the values for the classes via the @SerialName
annotation. If you want both, you'll have to go custom.Moroa Matshubeni
04/24/2024, 11:05 PM