put

fun put(key: String, value: JsonElement): JsonElement?(source)

Adds a custom metadata field with a JsonElement value.

Return

The previous value associated with the key, or null

Parameters

key

The metadata field name

value

The JsonElement value


fun put(key: String, value: String): JsonElement?(source)

Adds a custom metadata field with a String value.

Example: put("requestId", "req-456")


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

Adds a custom metadata field with a Number value.

Example: put("priority", 1)


fun put(key: String, value: Boolean): JsonElement?(source)

Adds a custom metadata field with a Boolean value.

Example: put("urgent", true)


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

Adds a custom metadata field with a null value.

Example: put("optionalField", null)