output-new-only not showing the right deltas for arrays
liuliu-dev opened this issue · 0 comments
liuliu-dev commented
have issues with diff deltas for arrays with outputNewOnly
- compare these two:
const a= '{
"array": [
1,
2,
3
],
"boolean": true,
"level2": {
"array": [
1,
2,
3
],
"boolean": true,
"null": null,
"number": 123,
"object": {
"a": "b",
"c": "d",
"e": "f"
},
"string": "Hello World"
},
"null": null,
"number": 123,
"object": {
"a": "b",
"c": "d",
"e": "f"
},
"string": "Hello World"
}'
and
const b='{
"array": [
1,
2,
3
],
"boolean": true,
"level2": {
"array": [
1,
2,
4
],
"boolean": true,
"null": null,
"number": 123,
"object": {
"a": "b",
"c": "d",
"e": "f"
},
"string": "Hello World"
},
"null": null,
"number": 123,
"object": {
"a": "b",
"c": "d",
"e": "a"
},
"string": "Hello World"
}'
the code I'm running is:
JSON.stringify(diff(JSON.parse(a),JSON.parse(b), { outputNewOnly: true }))
the result I got:
{
"level2": {
"array": [
[
" "
],
[
" "
],
[
"-",
2
],
[
"+",
4
],
]
},
"object": {
"e": "f"
}
}
can I get something like this?
{
"level2": {
"array": [
...,
[
"-",
2
],
[
"+",
4
]
]
},
"object": {
"e": "f"
}
}