jsondiff icon indicating copy to clipboard operation
jsondiff copied to clipboard

Incorrect diff for a string

Open vesperrin opened this issue 5 years ago • 2 comments

Hi, i've got two json files:

old.json

{
  "network": {
    "domain": "old.domain"
  }
}

new.json

{
  "network": {
    "domain": "new.domain"
  }
}

When i run:

jsondiff.diff(old_json, new_json, syntax="symmetric")

I've got this:

{
    "network": {
        "domain": [
            "old.domain",
            "new.domain"
        ]
    }
}

Instead of:

{
    "network": {
        "domain": {
            "$delete": [ "old.domain" ],
            "$insert": [ "new.domain" ]
        }
    }
}

The json expected that I've written is probably not right, it's just an example to show the diff keys I expect.

It is normal behavior? Did I forget something?

vesperrin avatar Feb 04 '20 11:02 vesperrin

Definitely looks like a bug. I reproduced it with the CLI tool and it works for non-symmetric:

> jsondiff old.json new.json -i 2
{
  "network": {
    "domain": "new.domain"
  }
}
> jsondiff old.json new.json -i 2 -s symmetric
{
  "network": {
    "domain": [
      "old.domain",
      "new.domain"
    ]
  }
}

mic-max avatar Apr 03 '20 23:04 mic-max