JsonObjectBuilder

class JsonObjectBuilder

DSL builder for a JsonObject. To create an instance of builder, use buildJsonObject build function.

Functions

Link copied to clipboard
fun put(key: String, element: JsonElement): JsonElement?

Add the given JSON element to a resulting JSON object using the given key.

Extensions

Link copied to clipboard
fun JsonObjectBuilder.put(key: String, value: Boolean?): JsonElement?

Add the given boolean value to a resulting JSON object using the given key.

fun JsonObjectBuilder.put(key: String, value: Number?): JsonElement?

Add the given numeric value to a resulting JSON object using the given key.

fun JsonObjectBuilder.put(key: String, value: String?): JsonElement?

Add the given string value to a resulting JSON object using the given key.

fun JsonObjectBuilder.put(key: String, value: Nothing?): JsonElement?

Add null to a resulting JSON object using the given key.

Link copied to clipboard
fun JsonObjectBuilder.putJsonArray(key: String, builderAction: JsonArrayBuilder.() -> Unit): JsonElement?

Add the JSON array produced by the builderAction function to a resulting JSON object using the given key.

Link copied to clipboard
fun JsonObjectBuilder.putJsonObject(key: String, builderAction: JsonObjectBuilder.() -> Unit): JsonElement?

Add the JSON object produced by the builderAction function to a resulting JSON object using the given key.