kotlinx-serialization / kotlinx.serialization.json / JsonObject

JsonObject

(common, js, jvm, native) data class JsonObject : JsonElement, Map<String, JsonElement>(common, js, native)

Class representing JSON object, consisting of name-value pairs, where value is arbitrary JsonElement

Since this class also implements Map interface, you can use traditional methods like Map.get or Map.getValue to obtain Json elements.

(jvm)

Class representing JSON object, consisting of name-value pairs, where value is arbitrary JsonElement

Since this class also implements Map interface, you can use traditional methods like Map.get or Map.getValue to obtain Json elements.

Constructors

(common, js, jvm, native)

<init>

Class representing JSON object, consisting of name-value pairs, where value is arbitrary JsonElement

<init>(content: Map<String, JsonElement>)

Properties

(common, js, jvm, native)

content

val content: Map<String, JsonElement>
(common, js, jvm, native)

jsonObject

Convenience method to get current element as JsonObject

val jsonObject: JsonObject

Functions

(common, js, jvm, native)

equals

fun equals(other: Any?): Boolean
(common, js, jvm, native)

getArray

Returns JsonArray associated with given key

fun getArray(key: String): JsonArray
(common, js, jvm, native)

getArrayOrNull

Returns JsonArray associated with given key or null if element is not present or has different type

fun getArrayOrNull(key: String): JsonArray?
(common, js, jvm, native)

getAs

Returns J associated with given key

fun <J : JsonElement> getAs(key: String): J
(common, js, jvm, native)

getAsOrNull

Returns J associated with given key or null if element is not present or has different type

fun <J : JsonElement> getAsOrNull(key: String): J?
(common, js, jvm, native)

getObject

Returns JsonObject associated with given key

fun getObject(key: String): JsonObject
(common, js, jvm, native)

getObjectOrNull

Returns JsonObject associated with given key or null if element is not present or has different type

fun getObjectOrNull(key: String): JsonObject?
(common, js, jvm, native)

getPrimitive

Returns JsonPrimitive associated with given key

fun getPrimitive(key: String): JsonPrimitive
(common, js, jvm, native)

getPrimitiveOrNull

Returns JsonPrimitive associated with given key or null if element is not present or has different type

fun getPrimitiveOrNull(key: String): JsonPrimitive?
(common, js, jvm, native)

hashCode

fun hashCode(): Int
(common, js, jvm, native)

toString

fun toString(): String