jsondiffpatch
jsondiffpatch copied to clipboard
False report on embedded arrays comparing
Please test this:
const jsondiffpatch = require('jsondiffpatch').create();
var obj1 = {
'test': {
'list': [
[
"5b51b577ed668594b0091b56",
"5b51fc4f695227a5977b716c"
],
0,
0
]
}
};
var obj2 = {
'test': {
'list': [
[
"5b51b577ed668594b0091b56",
"5b51fc4f695227a5977b716c"
],
0,
0
]
}
};
var delta = jsondiffpatch.diff(obj1, obj2);
console.log('Array delta', JSON.stringify(delta,null,2));
I expect the delta will be undefined
(because literally they are equal), but it gives:
Array delta {
"test": {
"list": {
"0": [
[
"5b51b577ed668594b0091b56",
"5b51fc4f695227a5977b716c"
]
],
"_t": "a",
"_0": [
[
"5b51b577ed668594b0091b56",
"5b51fc4f695227a5977b716c"
],
0,
0
]
}
}
}
It seems [..., 0, 0] of obj2 are ignored in comparing. Not knowing why.