diff-json icon indicating copy to clipboard operation
diff-json copied to clipboard

How to get an array of objects with key to show diff?

Open rmtuckerphx opened this issue 4 years ago • 2 comments

I have the following code:

var diffJson = require("diff-json")

oldArray = [
  {
    "id": "a",
    "count": 1
  },
  {
    "id": "b",
    "count": 0
  }
];

newArray = [
  {
    "id": "b",
    "count": 1
  },
  {
    "id": "a",
    "count": 3
  }
];

var diffs = diffJson.diff(oldArray, newArray);

And the result is showing as:

[Object {changes: [, ], embededKey: "$index", key: "$root", type: "update"}]

What should the call to .diff be? What do the other params (path, embededObjKeys, keyPath) mean?

rmtuckerphx avatar Apr 13 '20 14:04 rmtuckerphx