Shame on me.. I try to parse a
JSONN
Array
directly in my
KMM
setup with `ktor`and
KotlinxSerializer
and I donβt know how to define the
Data
class π
Exception
kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 1: Expected '{, kind: CLASS'
JSON input: ["Albania","Argentina","Austral.....
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
Respnse
[
"Albania",
"Argentina",
"Australia",
...
]
Data class
@Serializable
data class CountryDto(
val names: ArrayList<String>?
)
API Call
suspend fun fetchAll() = client.get<List<CountryDto>>(baseUrl)