json-patch / json-patch2

A possibile revision to the JSON-Patch format
44 stars 0 forks source link

Long text diffs #6

Open briancavalier opened 10 years ago

briancavalier commented 10 years ago

It could be useful in some situations to have a new patch operation for long text diffs, instead of replacing the text wholesale. For example, if you have an object with long text properties, etc.

This jsondiffpatch lib supports this kind of thing (using google's diff_match_patch lib), although it uses it's own patch format rather than JSON Patch. We've been discussing briefly over at cujojs/jiff#13 as well. Figured I would raise it here for discussion.

espadrine commented 7 years ago

I wholeheartedly agree.

It would be preferable to have operations in line with what already exists. The basic primitives of text edition are additions and removals, so it would fit quite well.

For instance, { "op": "add", "path": "/poem/4", "value": "canadian " } applied to {"poem": "The sled flew on the snow."} gives {"poem": "The canadian sled flew on the snow."}.

Similarly, { "op": "remove", "from": "/poem/4", "path": "/poem/13" } would remove the word "canadian".