jsondiffpatch.net
jsondiffpatch.net copied to clipboard
Options ignored due to DeepEquals
The features supported in Options like ExcludePath and DiffBehaviors are effectively ignored since JToken.DeepEquals doesn't take those into account.
If you exclude a path that would show up in an DeepEquals array scan, DeepEquals will still return false, even if every other path is valid. The same thing for IgnoreMissingProperties or IgnoreNewProperties.
Assuming you're not interested in writing your own DeepEquals, building an interface around that so that users can write their own would be helpful.
Do you have an example use case? The options you mentioned work fine in the context described in this issue: https://github.com/wbish/jsondiffpatch.net/issues/34
var json1 = (JToken)JsonConvert.DeserializeObject("[{\"id\":1,\"data\":100},{\"id\":2,\"data\":200},{\"id\":3,\"data\":300}]");
var json2 = (JToken)JsonConvert.DeserializeObject("[{\"id\":2,\"data\":200},{\"id\":3,\"data\":300}]");
Options options = new Options() { DiffBehaviors = DiffBehavior.IgnoreNewProperties };
var jdb = new JsonDiffPatch();
var patch = jdb.Diff(json1, json2);
If you run this, you'll see Diff will simply delete id 1 as expected. Add another property like so and you'll get very different results, despite the fact that IgnoreNewProperties is set.
var json2 = (JToken)JsonConvert.DeserializeObject("[{\"id\":2,\"data\":200,\"more\":20},{\"id\":3,\"data\":300}]");