json-patch/json-patch2

Long text diffs

briancavalier opened this issue · 1 comments

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.

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".