I am looking for a practical way to convert json string to a map using kotling (I do not have a data class for it as it will be mutable)
t
Temidjoy
07/25/2018, 12:10 PM
@rCorbellini
can you expound further, so i can get your question clearly
r
rCorbellini
07/25/2018, 12:14 PM
i Have a string Json and need it as a Map<key,value>
t
Temidjoy
07/25/2018, 12:32 PM
@rCorbellini
You should be able to achieve this with Klaxon. With this you can easily read the Json data as JsonObject which is actually a MutableMap.
Here is an example
val jsonResult: JsonObject = Parser().parse(jsonString) as JsonObject
https://github.com/cbeust/klaxon
g
gildor
07/25/2018, 1:36 PM
Use any Json library for that. Klaxon is written for Kotlin and on Kotlin, but nothing prevents you from usage of any Java library for that