News for hackers. Stuff that matters.
Re:JSON Patch – a format for describing changes to a JSON do... by nhaehnle on Thursday October 30, 2014 @04:37AM (#8531924)
It is my understanding that the JSON encoding of objects is not specified canonically because the order of keys can be arbitrary. That is, JSON.stringify() is free to return different strings for the same JSON object.

Is my understanding correct? If it is, that would totally break your suggestion.

Re:JSON Patch – a format for describing changes to a JSON do... by drostie on Thursday October 30, 2014 @01:29PM (#8534399)
You are correct, but if you control the environment enough to be doing this at all, then you control the environment enough to get the serialization consistent: either by having ordered dictionaries in the language a la Python and PHP, or implementing your own, or by sorting the keys lexicographically a la bencode.

That is, `diff(sorted_json_stringify(json_parse(p)))` will be adequate if `diff(p)` is not.