0

I am working on Kotlinx Serialisation and there is an error in serialising nested class.

This class is not serializable automatically because it has primary constructor parameters that are not properties

The workaround is to go with polymorphism using abstract/sealed class or with property variables, which is not the right way for my usecase. A sample code is given below.

@Serializable
open class A(val s: String) {}

@Serializable    //Error here
class B(s: String, val i: Int): A(s) {}

Is there any workaround for this?

0 Answers0