canonical-json-0.6.0.0: Canonical JSON for signing and hashing JSON values

Text.JSON.Canonical.Parse

Description

Minimal implementation of Canonical JSON parsing and printing.

http://wiki.laptop.org/go/Canonical_JSON

TODO: Known bugs/limitations:

• Decoding/encoding Unicode code-points beyond U+00ff is currently broken
Synopsis

# Documentation

Parse a canonical JSON format string as a JSON value. The input string does not have to be in canonical form, just in the "canonical JSON" format.

Use renderCanonicalJSON to convert into canonical form.

Render a JSON value in canonical form. This rendered form is canonical and so allows repeatable hashes.

For pretty printing, see prettyCanonicalJSON.

NB: Canonical JSON's string escaping rules deviate from RFC 7159 JSON which requires

"All Unicode characters may be placed within the quotation marks, except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F)."

Whereas the current specification of Canonical JSON explicitly requires to violate this by only escaping the quotation mark and the reverse solidus. This, however, contradicts Canonical JSON's statement that "Canonical JSON is parsable with any full JSON parser"

Consequently, Canonical JSON is not a proper subset of RFC 7159.

Render a JSON value in a reasonable human-readable form. This rendered form is not the canonical form used for repeatable hashes, use renderCanonicalJSON for that.