hagabaka
02/28/2018, 3:09 PMData
class with nullable fields, and a Base
class with a custom serializer which calls input.readValue() as Data
in load
and checks the null fields and constructs the right subtypesandwwraith
02/28/2018, 5:15 PMinput.readValue()
is not sufficient for deserializing, logic there is much more complicated – you should call readBegin()
, then read primitives field-by-field and so on. You can take a look on standard collection serializers (https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/common/src/main/kotlin/kotlinx/serialization/internal/CollectionSerializers.kt#L58 and https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/jvm/src/main/kotlin/kotlinx/serialization/PolymorphicSerializer.kt#L37) to get an idea what happens therehagabaka
02/28/2018, 5:20 PMinput.read(Data::class.serializer())
worked, but I'm still testing it