How to serialize/deserialize Kotlin sealed class?
问题 I have a following sealed class: sealed class ViewModel { data class Loaded(val value : String) : ViewModel() object Loading : ViewModel() } How can I serialize/deserialize instances of the ViewModel class, let's say to/from JSON format? I've tried to use Genson serializer/deserializer library - it can handle Kotlin data classes, it's also possible to support polymorphic types (eg. using some metadata to specify concrete types). However, the library fails on Kotlin object types, as these are