can I get a generic json object from a ktor-client...
# ktor
j
can I get a generic json object from a ktor-client call? Like I don’t know exactly what do endpoint will return, but I know for a fact that it has an
id
field and that’s all I need. I wanted to just
response.body()[id]
is that possible?
l
If that’s the case, you could make sure to set ignoreUnknownKeys when you create the json object, then create a serializable class with a single field id.
j
great, I was thinking about something like that. Thanks!
s
You can also deserialise to
kotlinx.serialization.json.JsonElement
and inspect it.