toMap

fun JsonElement.toMap(): Map<String, Any?>

Converts this JsonObject element to a Map of string keys to Kotlin values.

Extension function on JsonElement. Primitives become strings, nested objects become nested maps, arrays become lists, and JsonNull becomes null.

A primitive's string is its content. For parsed JSON that is the source text, so 1.0 stays "1.0". A number built in code carries the platform's rendering instead: JsonPrimitive(1.0) is "1.0" on the JVM but "1" on JS.

Return

a Map representation of this JSON object

Throws

if this element is not a JsonObject