josephburnett / jd

JSON diff and patch
MIT License
1.86k stars 51 forks source link

Fixes json patch apply code #9

Closed aftab-a closed 5 years ago

aftab-a commented 5 years ago

Patch command fails to apply patch to json if:-

  1. Patch is created using set mode. (jd -set)
  2. the json consists of nested maps
  3. Between jsons multiple elements are added to array in a nested element. E.g. File1 :- { "a": { "b": ["1", "2"], "c": ["3", "4"] } }

file2:- Aftab-MacBook:jsodiffTest aftab.ansari$ cat file4 { "a": { "b" : ["2", "1"], "c" : ["3", "4", "5", "6"] } }

Generated patch is as :- @ ["a","c",{}]

Fix involved fixing few of the checks done while patch is executed. Also added updated e2e test case to test the same. All tests are passing.