brinkhaustools::licence

Function canonical_json

Source
pub fn canonical_json(value: &Value) -> String
Expand description

Canonical JSON: object keys sorted, no insignificant whitespace.

Does not depend on serde_json’s preserve_order feature, which a consumer may enable for the whole build. Signatures cover the transmitted bytes, so the canonical form only has to be deterministic, not identical across languages — it is identical with Python’s json.dumps(sort_keys=True, separators=(",", ":"), ensure_ascii=False) for the payloads used here (integers and strings only), which the shared test vectors pin.