canonicalizeJson

fun canonicalizeJson(jsonString: String): String

Canonicalizes a JSON string by parsing and re-serializing with stable key ordering.

Return

The canonical JSON string

Parameters

jsonString

The JSON string to canonicalize

Throws


fun canonicalizeJson(element: JsonElement): String

Canonicalizes a JSON element by sorting keys lexicographically.

This ensures that the same JSON content always produces the same canonical form, regardless of key order in the original JSON.

Performance: Uses optimized JSON serialization with stable ordering.

Return

The canonical JSON string

Parameters

element

The JSON element to canonicalize