JsonObjectBuilder

class JsonObjectBuilder

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

Functions

put
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

put
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.

putJsonArray
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.

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

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