I use kotlinx.serialization
on Kotlin native project, I a defined Super class
for my models and all of the models extends from it.
I defined a function
to called toJSON()
for serialize variables and fields inside model that all of class models have it.
@Serializable
open class Model {
fun toJSON(): String = JSON.stringify(this);
}
And I created a subclass
class Me : Model() {
var name:String = "Jack";
}
but when I invoke JSON.stringify(this)
, IDE get a Warning to me:
This declaration is experimental and its usage must be marked with '@kotlinx.serialization.ImplicitReflectionSerializer' or '@UseExperimental(kotlinx.serialization.ImplicitReflectionSerializer::class)'
I paid attention and I used @ImplicitReflectionSerializer
annotation while not worked.
Where is my problem?