https://kotlinlang.org logo
#serialization
Title
# serialization
c

Ciprian Grigor

09/17/2021, 4:31 PM
Hi, I have a generic sealed class with specific type implementation how can I serialize it ?
Copy code
@Serializable
sealed class Base<T> {
    abstract val value: T

    @Serializable
    @SerialName("int")
    data class IntBase(override val value: Int) : Base<Int>()

    @Serializable
    @SerialName("string")
    data class StringBase(override val value: String) : Base<String>()
}