How to parse JSON in Kotlin?

AJ_1310 :

I'm receiving a quite deep JSON object string from a service which I must parse to a JSON object and then map it to classes.

How can I transform a JSON string to object in Kotlin?

After that the mapping to the respective classes, I was using StdDeserializer from Jackson. The problem arises at the moment the object had properties that also had to be deserialized into classes. I was not able to get the object mapper, at least I didn't know how, inside another deserializer.

Thanks in advance for any help. Preferably, natively, I'm trying to reduce the number of dependencies I need so if the answer is only for JSON manipulation and parsing it'd be enough.

Istiak Morsalin :

You can use this library https://github.com/cbeust/klaxon

Klaxon is a lightweight library to parse JSON in Kotlin.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=419323&siteId=1