Since XML Canonicalization has a reputation of not only being brittle but also
terribly slow, I tested JCS [1] with the following JSON file:
{
"1": {"f": {"f": "hi","F": 5} ,"\n": 56.0},
"10": { },
"": "empty",
"a": { },
"111": [ {"e": "yes","E": "no" } ],
"A": { }
}
Expected output:
{"":"empty","1":{"\n":56,"f":{"F":5,"f":"hi"}},"10":{},"111":[{"E":"no","e":"yes"}],"A":{},"a":{}}
Since JCS only is a serialization concept (parsing is unaffected), I compared
the execution speed of standard serialization versus canonicalized
serialization.
Using https://www.npmjs.com/package/canonicalize the performance penalty was
about 2.4 compared to JSON.stringify().
Using my homegrown JSON tools written in Java having an integrated
"canonicalize" serializer option the performance penalty was about 1.4
Anders
1] https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-01
_______________________________________________
jose mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/jose