Is my understanding correct? If it is, that would totally break your suggestion.
That is, `diff(sorted_json_stringify(json_parse(p)))` will be adequate if `diff(p)` is not.
2. This is in no way better at handling concurrent changes than anything other diff format. In fact, the extra operations it has do nothing to help you here (it is as good and bad as copy/add, or insert/delete diffs). I'd love to know why you seem to think otherwise.
JSON awareness only helps when trying to apply partial patches. At that point, the only thing it can possibly buy you is syntactic correctness, which is worthless without semantic correctness (and in fact, sometimes worse)
Doesn't this allow the sender to send updates without knowledge of the existing values, though? With a string diff, the existing value would have to be known.
> This is in no way better at handling concurrent changes than anything other diff format. In fact, the extra operations it has do nothing to help you here (it is as good and bad as copy/add, or insert/delete diffs). I'd love to know why you seem to think otherwise.
If you're sending a regular diff, you would clobber changes to other parts of the object if they were updated between your initial retrieval and subsequent change. But yeah, it doesn't seem to help with applying concurrent changes to the same part of an object, though I don't know if the patch format should shoulder that responsibility.
This system requires knowledge of existing values/nodes to create the diff/patch document.
However for JSON data, it does have the advantage of not clobbering data unlike a string diff as you mentioned.
A text-based diff doesn't really gain much for what it loses in use cases.
This seems like a trivial application of any copy/add delta format, which are easily expressed in text diff format.
Or are you simply talking about javascript style object literals?
From Wikipedia: JavaScript Object Notation, is an open standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs.
1. JSON.stringify()
2. Diff-match-patch: https://code.google.com/p/google-diff-match-patch/
3. JSON.parse()
There are several short-comings to the above approach though, specifically, you have to explicitly trade off performance vs. efficiency depending on the JSON you're dealing with.
JSON Patch is going to give you a consistent performance vs. efficiency curve which is desirable in a lot of circumstances.