kotlinx-serialization / kotlinx.serialization.json / JsonArray

JsonArray

(common, js, jvm, native) data class JsonArray : JsonElement, List<JsonElement>(common, js, native)

Class representing JSON array, consisting of indexed values, where value is arbitrary JsonElement

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

(jvm)

Class representing JSON array, consisting of indexed values, where value is arbitrary JsonElement

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

Constructors

(common, js, jvm, native)

<init>

Class representing JSON array, consisting of indexed values, where value is arbitrary JsonElement

<init>(content: List<JsonElement>)

Properties

(common, js, jvm, native)

content

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

jsonArray

Convenience method to get current element as JsonArray

val jsonArray: JsonArray

Functions

(common, js, jvm, native)

equals

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

getArray

Returns index-th element of an array as JsonArray

fun getArray(index: Int): JsonArray
(common, js, jvm, native)

getArrayOrNull

Returns index-th element of an array as JsonArray or null if element is missing or has different type

fun getArrayOrNull(index: Int): JsonArray?
(common, js, jvm, native)

getAs

Returns index-th element of an array as J

fun <J : JsonElement> getAs(index: Int): J
(common, js, jvm, native)

getAsOrNull

Returns index-th element of an array as J or null if element is missing or has different type

fun <J : JsonElement> getAsOrNull(index: Int): J?
(common, js, jvm, native)

getObject

Returns index-th element of an array as JsonObject

fun getObject(index: Int): JsonObject
(common, js, jvm, native)

getObjectOrNull

Returns index-th element of an array as JsonObject or null if element is missing or has different type

fun getObjectOrNull(index: Int): JsonObject?
(common, js, jvm, native)

getPrimitive

Returns index-th element of an array as JsonPrimitive

fun getPrimitive(index: Int): JsonPrimitive
(common, js, jvm, native)

getPrimitiveOrNull

Returns index-th element of an array as JsonPrimitive or null if element is missing or has different type

fun getPrimitiveOrNull(index: Int): JsonPrimitive?
(common, js, jvm, native)

hashCode

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

toString

fun toString(): String