Arpit Shukla
11/30/2021, 4:57 AMknthmn
11/30/2021, 6:32 AMKType
in SomeClass.version
, so you can use serializer(type: KType)
?Arpit Shukla
11/30/2021, 6:38 AMKType
? And how can I use that serializer to decode my json?knthmn
12/01/2021, 3:57 AMgetSomeObject()
fun getSomeObject(json: String, type: KType): SomeClass {
return Json.decodeFromString(serializer(type), json) as SomeClass
}
in SomeClass
val versions = arrayOf(typeOf<ClassV1>(), typeOf<ClassV2>())
Now there is also KClass.serializer()
but I am not sure if you are supposed to use itknthmn
12/01/2021, 6:24 AM