0

Basically the same issue as in - https://github.com/flipkart-incubator/zjsonpatch/issues/121

Is there a way to overcome this or Is there any alternate to JsonPatch library which gives the diff of 2 jsons similar to JsonPatch but with correct paths

Build diff using JsonDiff.asJson() with the following jsons:

Current

{
  "id": "Contract 1",
  "documents": [
    {
      "id": "1",
      "name": "First document"
    },
    {
      "id": "2",
      "name": "Second document"
    },
    {
      "id": "3",
      "name": "Third document"
    }
  ]
}

Modified

{
  "id": "Contract 1",
  "documents": [
    {
      "id": "1",
      "name": "First document"
    }
  ]
}

Removed last two objects from array

Expected Behavior Json Patch document

[
    {
        "op": "remove",
        "path": "/documents/2"
    },
    {
        "op": "remove",
        "path": "/documents/1"
    }
]

Actual Behavior Json Patch document

[
    {
        "op": "remove",
        "path": "/documents/1"
    },
    {
        "op": "remove",
        "path": "/documents/1"
    }
]

0 Answers0