Skip to main content

Module canonical

Module canonical 

Source
Expand description

canonical — canonical-serialization.md reference implementation.

Three primitives:

  • py_float_repr(n) : CPython repr(float) byte-identical decimal.
  • canonical_value(v) : key identity (top-level keys sorted only).
  • canonical_json(v) : fingerprint (all levels key-sorted; arrays keep order).

Object-key sort is Unicode code-point order across all languages. Rust str Ord is UTF-8 byte order which equals code-point order, so sort() on &str/String is the normative comparator (verified by the astral vector).

Structs§

CanonicalFailure

Enums§

CanonicalFailureCode

Functions§

canonical_json
Fingerprint canonical serialization: all object levels code-point key-sorted; arrays keep order.
canonical_value
Key-identity canonical serialization: only the top-level object’s keys are code-point sorted; nested values keep insertion order.
py_float_repr
Render f exactly as CPython repr(float) / json.dumps(float) would. Finite floats only; NaN/±Inf return a Failure.