Skip to content

JsonDiff bug found #163

Open
Open
@fmoghaddam

Description

@fmoghaddam

Consider the following Jsons:

Source:

{
    "store": {
        "a": [
            "v1",
            "v2"
        ]
    }
}

Target:

{
    "store": {
        "a": []
    }
}

running JsonDiff.asJson(source, target) returns:

[ {
  "op" : "remove",
  "path" : "/store/a/0"
}, {
  "op" : "remove",
  "path" : "/store/a/0"
} ]

which as it is seen both path is same but actually the next path should be "/store/a/1". The reason is there is a bug in JsonDiff class in function generateArrayDiffs. There is a for loop as:

for(index = size; index < firstSize; ++index) {
   processor.valueRemoved(pointer.append(size), source.get(index));
}

Which should be changed to:

for(index = size; index < firstSize; ++index) {
   processor.valueRemoved(pointer.append(index), source.get(index));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions