Hi I am a newbie to kotlinx serialization and I am using KMP, my requirement is a little different
my data class
@Serializable data class Student(val name : String , val age : Int)
and my simple JSON would be "['Avinash', 22]",
which should be deserialized to Student("Avinash", 22)
I'm not able to deserialize it can anyone help me
Try this:
Pay attention how to format your JSON string.
[]
square brackets are for arrays{}
curly brackets are for objectsAnd you must provide your fields name, and use double quotes for fields and values, or use a less strict
Json
deserialization:If you want a deep view on json schema, you can read here.