Skip to main content

Module canonical

Module canonical 

Source
Expand description

Canonical JSON serialization per SPEC §5.

Given a serde_json::Value, produce the canonical byte sequence that is the input to SHA-256 content addressing (§6). Rules:

  1. Object keys sorted by NFC-normalized UTF-8 bytes (§5.1).
  2. No whitespace between tokens (§5.1).
  3. Strings NFC-normalized before emission (§5.2).
  4. Numbers in shortest round-trip decimal form (§5.3).
  5. -0 normalizes to 0 (§5.3).

Functions§

to_bytes
Serialize a serde_json::Value to canonical bytes (SPEC §5).