I have following code in Kotlin:
sealed class ParentClass
data class ChildA(val prop: String): ParentClass()
object ChildB: ParentClass()
but when I try to serialize it into JSON with Moshi I get following Error:
Caused by: java.lang.IllegalArgumentException: Cannot serialize object declaration ChildB
Failed to serialize obj: ChildB of type: class ChildB to a map
I don't want to include full stack trace due to confidentiality, but essentially it fails on this line. I wonder if there is a way to serialize Kotlin object types into JSON and back?