Joost Klitsie
03/14/2021, 3:19 PM{
"solution": {
"type": "com.klitsie.pubquiz.common.question.solution.SolutionV0.SingleSolutionV0",
"solution": "123",
"id": "8db60275-45ae-4ba3-a463-8cac0cd5afce"
}
}
{
"solution": "123",
"id": "514df2d1-ffc9-4691-9087-6af334721811"
}
Json {
ignoreUnknownKeys = true
isLenient = true
prettyPrint = true
}
crummy
03/14/2021, 6:41 PMJoost Klitsie
03/14/2021, 7:18 PMRustam Siniukov
03/15/2021, 9:18 AMuseArrayPolymorphism = false
in your Json { }
block helps?Joost Klitsie
03/15/2021, 11:47 AM// WRONG
val mySeleadClass = SealedClass.Whatever("whatever")
call.respond(mySeleadClass )
// RIGHT
val mySeleadClass = SealedClass.Whatever("whatever")
call.respond<SealedClass>(mySeleadClass)
Because if you do not infer the type of the actual parent sealed class, it will simply serialize the child class as if it would be a stand alone the child class (and it will not be treated as a sealed class at all).
https://github.com/Kotlin/kotlinx.serialization/issues/1194