Why does that throw an exception? (thread)
j
Why does that throw an exception? (thread)
Copy code
Json.decodeFromString<String>(
        """
    [
    
    ]
        """.trimIndent()
)
Copy code
Exception in thread "main" kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected beginning of the string, but got [
JSON input: [
]
I used HttpResponse#body<String> and got the same error thats why I tried that
d
Well, you want
String
but that's not a string, hence the exception.
Are you just trying to get the response as text? Or are you expecting a JSON string?
j
Json Array or object
but I could just decode it as JsonElement right?
d
Yeah
j
ok then I'm gonna do that thanks