can kotlinx.serialization be convinced to allow for some non-exact class matches when polymorphic?
I'd like to use it on various data structures containing
CharSequence
. regardless of the exact type, I want to handle them all the same way - serialize their
.toString()
, and a subset of their spans if
Spannable
(Android interface), ignoring everything else. but it seems like polymorphic(CharSequence::class) is forcing me to write a separate serializer for every possible concrete class
ephemient
07/06/2020, 10:41 PM
to answer my own question, I've ended up writing my own serializer and registering it with
@file:UseSerializers
on top of all the classes containing CharSequence. annoyingly, it doesn't seem possible to affect serialization of fields within classes not under my direct control.