vr-jcs
RFC 8785 JSON Canonicalization Scheme (JCS) for deterministic serialization.
vr-jcs produces RFC 8785 canonical JSON suitable for deterministic digest computation, content hashing, and stable serialization boundaries. Originally developed for the VertRule receipt infrastructure, it is suitable for any context requiring reproducible JSON output.
What it does
- Sorts object property names by UTF-16 code units
- Renders numbers using ECMAScript-compatible formatting (via
zmij) - Emits canonical JSON with no insignificant whitespace
- Validates I-JSON string constraints (noncharacter rejection)
- Rejects duplicate property names on raw JSON parse paths
What it does not do
- It is not a general-purpose JSON transformation toolkit
- It does not invent semantics beyond canonicalization
- Duplicate-key rejection applies to raw JSON parse helpers; typed
Serializeinputs do not carry duplicate keys
Usage
use to_canon_string_from_str;
API
| Function | Description |
|---|---|
to_canon_bytes_from_slice |
Parse raw JSON bytes, reject duplicates, return canonical bytes |
to_canon_string_from_str |
Parse raw JSON string, reject duplicates, return canonical string |
canonicalize |
Sort object keys in-place by UTF-16 code units |
to_canon_bytes |
(deprecated) Serialize a Serialize type to canonical JSON bytes |
to_canon_string |
(deprecated) Serialize a Serialize type to a canonical JSON string |
All functions return Result<_, JcsError>.
License
Licensed under Apache-2.0. See LICENSE for details.