Shame on me.. I try to parse a `JSONN` `Array` d...
# serialization
m
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
Copy code
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
Copy code
[
    "Albania",
    "Argentina",
    "Australia",
...
]
Data class
Copy code
@Serializable
data class CountryDto(
    val names: ArrayList<String>?
)
API Call
Copy code
suspend fun fetchAll() = client.get<List<CountryDto>>(baseUrl)
j
You are defining a list of lists, when you have a single list of strings
get<List<String>>
😎 1
🙏 1
m
OMG
and I was trying to fix it on my data class 🙂 it works …
muchos gracias
🙂 1