jsondiffpatch.net icon indicating copy to clipboard operation
jsondiffpatch.net copied to clipboard

ArrayDiff with ExcludePaths incorrectly fails

Open MaximeJonckheere opened this issue 3 years ago • 1 comments

When comparing an object containing an array, using an exclude path for a property in that array incorrectly returns { "_t": "a" }.

Example:

{
    "User": {
        "Adresses": [
            {
                "Id": "eb369327-2321-4ae2-bb2f-4d74dff1a70d",
                "Street": "Streetname"
            }
        ]
    }
}

In this example, I want to compare this object. But I want to ignore the Id property. Using "User.Adresses[0].Id" in exclude paths, I can ignore this value.

But the result of the Diff is :

{
  "User": {
    "Adresses": {
      "_t": "a"
    }
  }
}

I see the following in the source code in the beginning of the ArrayDiff method:

var result = JObject.Parse(@"{ ""_t"": ""a"" }");

Because there is no difference between the two values (ignoring the excluded paths), this result object is returned. In this case, when there is no difference, this method should return null instead.

MaximeJonckheere avatar Feb 16 '22 13:02 MaximeJonckheere

Same issue relevant for me :D

TomaszSiudak avatar May 05 '22 08:05 TomaszSiudak