Closed jkomoros closed 6 years ago
Contents of a.json:
{ "array": [] }
Contents of b.json:
{ "array": [3,4,5] }
Execute: jd a.json b.json > diff.patch
jd a.json b.json > diff.patch
Contents of diff.patch:
@ ["array",2] + 5 @ ["array",1] + 4 @ ["array",0] + 3
Execute: jd -p diff.patch a.json
jd -p diff.patch a.json
Result (error): Addition beyond the terminal elemtn of an array.
Addition beyond the terminal elemtn of an array.
Expected result: {"array":[3,4,5]}
{"array":[3,4,5]}
However, if you manually edit the contents of diff.patch to:
@ ["array",0] + 3 @ ["array",1] + 4 @ ["array",2] + 5
Then it works as expected.
It seems like the diff for this case outputs the array indexes in reverse order.
It's entirely possible I'm holding it wrong. Sorry for the noise if so!
You are correct. It's emitting the patch chunks in the wrong order such that they cannot be applied. Good catch!
@jkomoros, thanks for the report. I've submitted a change to fix this.
Contents of a.json:
Contents of b.json:
Execute:
jd a.json b.json > diff.patch
Contents of diff.patch:
Execute:
jd -p diff.patch a.json
Result (error):
Addition beyond the terminal elemtn of an array.
Expected result:
{"array":[3,4,5]}
However, if you manually edit the contents of diff.patch to:
Then it works as expected.
It seems like the diff for this case outputs the array indexes in reverse order.
It's entirely possible I'm holding it wrong. Sorry for the noise if so!