Hello, I have a custom format and Encoder/Decoder,...
# serialization
j
Hello, I have a custom format and Encoder/Decoder, however, it is just for top-level properties, the more complex (nested) inner values would be converted to json. Is there a way to delegate to
JsonEncoder
? I think I should return
JsonEncoder
instance (
JsonTreeEncoder
?) in my
beginStructure
method, but everything related to Json encoding seems to be internal. Is there a way? Thank you.
Oh, it seems I can branch a bit earlier this way:
Copy code
override fun <T> encodeSerializableValue(serializer: SerializationStrategy<T>, value: T) {
    val isSupported = value is ...
    if (isSupported) {
        super.encodeSerializableValue(serializer, value)
    } else {
        encodeString(Json.encodeToString(serializer, value))
    }
}