Hi there!
Facing troubles with Serialization… Could someone explain me what’s wrong and what I need to do? Using serialization 1.6.10…
Copy code
sealed interface Convertible {
fun convertUserInput(value : String): String
}
@Serializable
@SerialName("CustomConvertible")
class CustomConvertible(): Convertible {
override fun convertUserInput(value : String): String {
return ""
}
}
@Serializable
class DTOAttribute(val convertibles : List<Convertible> = emptyList())
Later on, I’d like to encode the
DTOAttribute
with
val string = Json.encodeToString(dtoAttr)
Calling this, gives me the following exception:
Copy code
kotlinx.serialization.SerializationException: Class 'CustomConvertible' is not registered for polymorphic serialization in the scope of 'Convertible'.
Mark the base class as 'sealed' or register the serializer explicitly.