JsonObjectBuilder

JSON Object Builder for nested structures.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun build(): JsonObject

Build nested JSON object.

Link copied to clipboard
operator fun String.invoke(block: JsonObjectBuilder.() -> Unit)

Set a nested property with a nested object builder.

Link copied to clipboard
fun put(key: String, value: Boolean)

Put a property value (boolean).

fun put(key: String, block: JsonObjectBuilder.() -> Unit)

Put a nested JSON object.

fun put(key: String, value: Number)

Put a property value (number).

fun put(key: String, value: String)

Put a property value.

fun put(key: String, values: List<JsonElement>)

Put a JSON array.

fun put(key: String, value: JsonObject)

Put a JsonObject directly.

Link copied to clipboard
infix fun String.to(value: Any?)

Set a nested property.

infix fun String.to(blocks: List<JsonObjectBuilder.() -> Unit>)

Set an array property with a list of object builders. This allows creating arrays of objects using DSL syntax.