Open danielweck opened 6 years ago
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.
Also see improved JSON "stringify" solutions: https://github.com/epoberezkin/fast-json-stable-stringify
See: https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-01 https://github.com/cyberphone/json-canonicalization https://github.com/erdtman/canonicalize