Package-level declarations

Types

Link copied to clipboard

Pre-configured Json instances for common serialization scenarios.

Link copied to clipboard

Default Json configuration used by the conversion utilities in this file.

Link copied to clipboard

Formerly the internal logger holder for JSON element utilities.

Properties

Link copied to clipboard
val JsonElement.booleanValue: Boolean

Returns the boolean value of this JsonElement's primitive content. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.doubleValue: Double

Returns the double value of this JsonElement's primitive content. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.intValue: Int

Returns the integer value of this JsonElement's primitive content. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.isArray: Boolean

Returns true if this JsonElement is a JsonArray. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.isNumber: Boolean

Returns true if this JsonElement is an unquoted numeric JsonPrimitive. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.isObject: Boolean

Returns true if this JsonElement is a JsonObject. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.isPrimitive: Boolean

Returns true if this JsonElement is a JsonPrimitive. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.isString: Boolean

Returns true if this JsonElement is a string JsonPrimitive. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.jsonObjectValue: JsonObject

Returns this JsonElement as a JsonObject. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.keys: Set<String>

Returns the set of keys if this JsonElement is a JsonObject. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.longValue: Long

Returns the Long value of this JsonElement's primitive content, for values such as IDs and millisecond timestamps that exceed Int. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.size: Int

Returns the number of entries in a JsonObject or elements in a JsonArray. Extension property on JsonElement.

Link copied to clipboard
val JsonElement.stringValue: String

Returns the string content of this JsonElement as a JsonPrimitive. Extension property on JsonElement.

Functions

Link copied to clipboard
fun JsonElement.booleanValue(vararg keys: String): Boolean

Navigates to the nested element at keys and returns its boolean value. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.booleanValueOrNull(vararg keys: String): Boolean?

Navigates to the nested element at keys and returns its boolean value, or null if it is missing, JSON null, or not true or false. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.containsKeys(vararg keys: String): Boolean

Checks whether this JsonElement contains the nested path specified by keys.

Link copied to clipboard
fun JsonElement.deepCopy(): JsonElement

Creates a deep copy of this JsonElement, rebuilding every nested object and array. Primitives are immutable, so they are shared. Extension function on JsonElement.

Link copied to clipboard
fun JsonBuilder.defaultJsonConfig()

Applies the default JSON configuration (pretty-print with two-space indent) to this JsonBuilder.

Link copied to clipboard
fun JsonElement.doubleValue(vararg keys: String): Double

Navigates to the nested element at keys and returns its double value. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.doubleValueOrNull(vararg keys: String): Double?

Navigates to the nested element at keys and returns its double value, or null if it is missing, JSON null, or not a number. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.forEachJsonObject(action: (JsonObject) -> Unit)

Iterates over JsonObject elements within this JsonElement.

Link copied to clipboard
operator fun JsonElement.get(vararg keys: String): JsonElement

Navigates into nested JsonObject children using dot-separated key strings.

Link copied to clipboard
fun JsonElement.getByPath(path: String): JsonElement?

Traverses this JsonElement using a slash-delimited path (e.g., "a/b/c").

Link copied to clipboard
fun JsonElement.getOrNull(vararg keys: String): JsonElement?

Navigates into nested children like get, but returns null if any key is missing or the value is JsonNull.

Link copied to clipboard
fun JsonElement.intValue(vararg keys: String): Int

Navigates to the nested element at keys and returns its integer value. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.intValueOrNull(vararg keys: String): Int?

Navigates to the nested element at keys and returns its integer value, or null if it is missing, JSON null, or not an integer. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.isEmpty(): Boolean

Returns true if this JsonElement is empty: an object with no keys, an array with no elements, JSON null, or a primitive whose content is the empty string. A whitespace-only string is not empty.

Link copied to clipboard
fun JsonElement.isNotEmpty(): Boolean

Returns true if this JsonElement is not empty. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.jsonElementList(vararg keys: String): List<JsonElement>

Navigates to the nested element at keys and returns it as a list of JsonElement. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.jsonElementListOrNull(vararg keys: String): List<JsonElement>?

Navigates to the nested element at keys and returns it as a list of JsonElement, or null if it is missing, JSON null, or not an array. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.jsonObjectValue(vararg keys: String): JsonObject

Navigates to the nested element at keys and returns it as a JsonObject. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.jsonObjectValueOrNull(vararg keys: String): JsonObject?

Navigates to the nested element at keys and returns it as a JsonObject, or null if it is missing, JSON null, or not an object. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.longValue(vararg keys: String): Long

Navigates to the nested element at keys and returns its Long value. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.longValueOrNull(vararg keys: String): Long?

Navigates to the nested element at keys and returns its Long value, or null if it is missing, JSON null, or not an integer in range. Extension function on JsonElement.

Link copied to clipboard
fun String.parseJson(verbose: Boolean = false): JsonElement

Parses this String as JSON text into a JsonElement.

Link copied to clipboard
fun String.reformatJson(prettyPrint: Boolean = true): String

Parses this String as JSON and re-encodes it. Extension function on String.

Link copied to clipboard
fun JsonElement.stringValue(vararg keys: String): String

Navigates to the nested element at keys and returns its string value. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.stringValueOrNull(vararg keys: String): String?

Navigates to the nested element at keys and returns its string value, or null if it is missing, JSON null, or not a primitive. Extension function on JsonElement.

Link copied to clipboard
fun JsonElement.toFormattedString(indent: String = " "): String

Encodes this JsonElement as a pretty-printed JSON string.

Link copied to clipboard
inline fun <T> T.toJsonElement(): JsonElement

Converts this value to a JsonElement tree using kotlinx.serialization.

fun String.toJsonElement(verbose: Boolean = false): JsonElement

Parses this String as JSON text into a JsonElement; renamed parseJson.

Link copied to clipboard
fun JsonElement.toJsonElementList(): List<JsonElement>

Converts this JsonElement (which must be a JsonArray) to a List of JsonElement. Extension function on JsonElement.

Link copied to clipboard

Parses this String as JSON and re-encodes it as a pretty-printed JSON string. Extension function on String.

inline fun <T> T.toJsonString(prettyPrint: Boolean = true): String

Serializes this value to a JSON string.

Link copied to clipboard
fun JsonElement.toMap(): Map<String, Any?>

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