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

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 a 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.size: Int

Returns the number of entries if this JsonElement is a JsonObject. 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 not found. 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 by serializing and deserializing it. 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 not found. 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 not found. Extension function on JsonElement.

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

Returns true if this JsonElement is empty (no keys for objects, no items for arrays, blank for primitives).

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 not found. 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 not found. Extension function on JsonElement.

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 not found. 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 into a JsonElement.

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.