Skip to content

Diff of identical objects with nested arrays causes invalid diff when there should be none #420

@ted-kramer

Description

@ted-kramer
let testValueA = {
   A: [
       ["B"],
       1,
       "C",
       2,
      "C"
   ]
}
let testValueB = structuredClone(testValueA);
let delta = jsondiffpatch.diff(testValueA, testValueB);

delta should be undefined but instead its:

{
  "A": {
    "0": [
      [
        "B"
      ]
    ],
    "_t": "a",
    "_0": [
      [
        "B"
      ],
      0,
      0
    ]
  }
}

It appears that this structure is somehow tripping up the diff algorithm. Stumbled on this randomly when some deeply nested config files happened to cause this to occur. I tried the array config options and neither made any difference in output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions