Expand description
Python-compatible canonical JSON encoding.
Dataset checksums are sha256 over the exact bytes Python produces with
json.dumps(payload, sort_keys=True, separators=(",", ":")). Two spots
diverge from serde_json’s encoder and are reimplemented here:
- floats: Python uses
repr(float)(shortest round-trip, scientific notation when the decimal exponent is < -4 or >= 16, two-digit exponent with sign), where ryu prefers positional notation; - strings: Python defaults to
ensure_ascii=True, escaping any non-ASCII character as\uXXXX(surrogate pairs above the BMP).
Map keys are already sorted because serde_json::Map is a BTreeMap
(byte order == code-point order for the ASCII keys used by the schema).
Functions§
- canonical_
json - Serialize
valueexactly as Python’sjson.dumps(value, sort_keys=True, separators=(",", ":")). - canonical_
json_ pretty - Serialize
valueexactly as Python’sjson.dumps(value, indent=2, sort_keys=True) + "\n"— used for the checkpoint manifest, which humans read directly. - python_
float_ repr - Format an f64 exactly like CPython’s
repr(float).