(That is, create a diff, then validate that applying the diff to the left input produces the right output.)
Expected output:
{}
(That is, the diff successfully creates right.json)
Actual output:
{
"Indexes": {
"_0": [
-1,
0,
0
],
"_t": "a"
}
}
(That is, derived_right.json is different from right.json)
If you inspect dervied_right.json you see:
{
"Indexes": [
-1,
-1
]
}
(That is, derived_right.json is missing one row)
I originally came across this with a much larger json diff, but reduced to this test case with trial and error. Oddly enough, the behavior appears to rely on the values of the integer constants in the left.json. For example, if you flip the position of 2 and 1 in left.json, it works as expected.
Note that I also was seeing similar behavior for an array that was not integer constants, but strings that went from "somevalue" to "" if they were in the first position in the array. I factored them out of the test case because the integer test case still triggered.
I ran into a case where the diff output appears to be incorrect. What follows is a reduced test case.
Contents of
left.json
:Contents of
right.json
:Run the following:
(That is, create a diff, then validate that applying the diff to the left input produces the right output.)
Expected output:
(That is, the diff successfully creates right.json)
Actual output:
(That is,
derived_right.json
is different fromright.json
)If you inspect
dervied_right.json
you see:(That is,
derived_right.json
is missing one row)I originally came across this with a much larger json diff, but reduced to this test case with trial and error. Oddly enough, the behavior appears to rely on the values of the integer constants in the left.json. For example, if you flip the position of
2
and1
in left.json, it works as expected.Note that I also was seeing similar behavior for an array that was not integer constants, but strings that went from "somevalue" to "" if they were in the first position in the array. I factored them out of the test case because the integer test case still triggered.
I think that the original jsondiffpatch works correctly in this case, at least based on using the webapp version: https://benjamine.github.io/jsondiffpatch/demo/index.html
I'm using the 0.0.2 version of the
jd
toolApologies if I'm missing something obvious or not using this as intended!