andreyvit / json-diff

Structural diff for JSON files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perform string diff on strings

FireyFly opened this issue · comments

As you're no doubt familiar with, Github's diffs show not only which lines have changed, but also frequently which bits of the line changed, when you make changes to an already existing line.

I'm not sure exactly how this is implemented, but I imagine it would be something like: perform the usual diff algorithm using lines as "atoms". Then, if the resulting diff would have a - followed by +, perform a char-by-char diff of these two lines. If the lines are at least n% similar, highlight the char-by-char diff in a stronger formatting to emphasize which bits of the line changed.

I think something similar for string values in the JSON data would be very handy. In the particular JSON data I've worked with, I'm importing data from a source, and from one import to the next there might've been typo fixes or small changes to description strings in the data. It would be very convenient to be able to tell at a glance exactly which bits were added/removed. So, I think it would be nice to perform a standard char-by-char diff of string values, if there is a - of a string value, followed by a + of a string value.