JsonDataBuilder

Typed JSON object builder. Callers stay in plain Kotlin types — no JsonElement / buildJsonObject / put in user code:

jsonData {
"floodDepthCm" to 75.0
"stationId" to "STA-42"
"location" {
"lat" to 40.7128
"lon" to -74.0060
}
"tags" to listOf("flood", "urgent")
}

Used across the framework anywhere a JsonObject payload is needed (contract trigger data, contract draft data, VC subject claims, audit records, …).

Constructors

Link copied to clipboard
constructor()

Functions

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

Nested object using "key" { ... } syntax.

Link copied to clipboard
@JvmName(name = "toAny")
infix fun String.to(value: Any?)

Catch-all overload that accepts nullable primitives (String?, Int?, etc.) and arbitrary Any? values. Resolves only when the typed overloads above don't match. null becomes JsonNull.

infix fun String.to(value: Boolean)
infix fun String.to(value: Nothing?)
infix fun String.to(value: Number)
infix fun String.to(value: String)
infix fun String.to(value: List<*>)

infix fun String.to(block: JsonDataBuilder.() -> Unit)

Nested object using "key" to { ... } syntax.

infix fun String.to(value: JsonElement)

Escape hatch for callers that already hold a raw JsonElement (e.g. extracted from a credential subject). Prefer the typed forms above.