zgrossbart / jdd

A semantic JSON compare tool
http://www.jsondiff.com
Apache License 2.0
1.03k stars 180 forks source link

Doesn't understand insertion/deletion in the middle of a list #47

Open andreareina opened 2 years ago

andreareina commented 2 years ago

Left: [1,2,3,4] Right: [1,2,4]

Expected outcome:

zgrossbart commented 2 years ago

Hello @andreareina. Thank you for using JSONDiff.

In this case you have two arrays that look like this:

Element Left Side Right Side
0 1 1
1 2 2
2 3 4
3 4 missing

In this case there are two differences between these two arrays. The first difference is that the second elements have different values: The left-side value is 3 and the right-side value is 4. The second difference is that the right-side array is missing the third value.

This would be a little easier to see if the arrays had different values. Like this:

Left: ["apple", "banana", "orange", "pear"] Right: ["apple", "banana", "pear"]

Element Left Side Right Side
0 apple apple
1 banana banana
2 pear orange
3 orange missing

In this case the two difference would be:

Both sides should be equal strings

and

Missing element 3 from the array on the right side

Does that help explain what's going on here and why you see two difference instead of one?