Thread
#serialization
    m

    marzelwidmer

    1 year ago
    Shame on me.. I try to parse a
    JSONN
    Array
    directly in my
    KMM
    setup with ktorand
    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)
    Javier

    Javier

    1 year ago
    You are defining a list of lists, when you have a single list of strings
    get<List<String>>
    m

    marzelwidmer

    1 year ago
    OMG
    and I was trying to fix it on my data class 🙂 it works …
    muchos gracias