Is it possible to deserialize JSON into its basic ...
# serialization
c
Is it possible to deserialize JSON into its basic untyped structure of just Maps, Lists, and primitives?
g
But Map and List are typed data structures in Kotlin
c
No, I’m wanting to get the abstract JSON tree from a String input, but where all values are either
Map<String, Any>
,
List<Any>
, or a primitive. Basically, I want to get back the equivalent of
JsonElement
but without the wrapper classes, just the nested values of the elements https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/common/src/main/kotlin/kotlinx/serialization/json/JsonElement.kt
Using the org.json library, I can do
new JSONObject(json).toMap()
, I’m wanting an equivalent method here