# Open Print canonical JSON

Signatures need one predictable byte sequence. Ordinary JSON does not provide
one: the same object can be written with different spacing or key order.

Open Print 1.0 calls its encoding `open-print-c14n-1`. It follows these rules:

1. Object keys are sorted by their UTF-16 code units.
2. Objects contain no insignificant whitespace.
3. Arrays keep their original order.
4. Strings, booleans, `null`, and finite numbers use JavaScript’s standard JSON
   spelling.
5. Object properties whose value is `undefined` are omitted.
6. `undefined` array entries, functions, symbols, bigint values, `NaN`, and
   infinities are rejected.
7. Cycles and non-JSON objects such as `Date`, `Map`, and class instances are
   rejected.

The UTF-8 bytes of that string are hashed or signed.

The rules intentionally describe a JSON data model, not arbitrary JavaScript
objects. Applications should validate a record against its schema before
canonicalizing it.

Every integer in a published Open Print schema is limited to the portable
range from `-9007199254740991` to `9007199254740991`. Current sequence and
registry-length fields are non-negative. This prevents implementations from
disagreeing after a number exceeds JavaScript's exact integer range.

Changing these rules would invalidate existing signatures, so
`open-print-c14n-1` is frozen for the 1.x line. A future encoding must use a new
name and a new major version.
