r2-streamer-js icon indicating copy to clipboard operation
r2-streamer-js copied to clipboard

Lexicographically canonical JSON form of "Readium webpub manifest"

Open danielweck opened this issue 7 years ago • 2 comments

See: https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-01 https://github.com/cyberphone/json-canonicalization https://github.com/erdtman/canonicalize

danielweck avatar Aug 20 '18 18:08 danielweck

Note that there are several "competing" proposals for various definitions of "canonical" JSON, e.g.

https://github.com/gibson042/canonicaljson-spec https://github.com/gibson042/canonicaljson-go

http://wiki.laptop.org/go/Canonical_JSON https://github.com/well-typed/canonical-json

https://github.com/mirkokiefer/canonical-json https://github.com/davidchambers/CANON

https://keybase.io/docs/api/1.0/canonical_packings#json

https://bigeasy.github.io/keyify/docco/keyify.js.html https://github.com/bigeasy/keyify

...as exemplified by this expansive discussion thread: https://esdiscuss.org/topic/json-canonicalize https://mail.mozilla.org/pipermail/es-discuss/2018-March/thread.html#50334

However, in our limited use-case we would in fact not have to deal with sophisticated normalization of unicode strings (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize ) and/or number types, mostly just removal of insignificant whitespace in the serialized representation ("stringify-ed" JSON), and sorting of object properties / keys as per their lexicographic (alphabetical) order.

danielweck avatar Aug 20 '18 18:08 danielweck

Also see improved JSON "stringify" solutions: https://github.com/epoberezkin/fast-json-stable-stringify

danielweck avatar Aug 22 '18 18:08 danielweck