I'm making a request to a request to an API and the response is a JSON object, this json object contains a string that is another json object. I'm trying to use kotlinx.serialization to handle the deserialization of this object.
I could override the deserialize functionality myself but that kind of defeats the point of using this library
I hoped something like this would have worked.
@Serializable
data class Foo(val data: Data)
@Serializable
data class Data(val foo: String)
For something like the following Object
{
"data":"{\"foo\":\"bar\"}"
}
I expect to get an Object Foo with property data = Object Data with property foo = "bar"
However I get the following error
java.lang.IllegalStateException: Expected class kotlinx.serialization.json.JsonArray (Kotlin reflection is not available) but found class kotlinx.serialization.json.JsonLiteral (Kotlin reflection is not available)