jsondiffpatch.net
jsondiffpatch.net copied to clipboard
Case sensitivity and order while comparing values
- Is there any way in this library to ignore cases while comparing ?
- Also to ignore the order of values in array
Example: array1 = [ "Audi", "toyota", "merc"]; array2 = [ "toyota", "audi", "merc"];
output: It should treat both array1 and array2 as same (as they have same values in different order and different cases i.e. capital and lowercases)
Any update on this one ?
No, feel free to add these features and submit a PR. Unfortunately, I don't have time to work on these.
For the first one I think maybe the right approach would be to expose an comparer interface people can implement and pass into JsonDiffPatch -- that way we can support weird cases like (int)1 == (string)"1"
The second one exists in the original JsonDiffPatch library already and something we should definitely add. Search for "detectMove" in benjamine/jsondiffpatch (https://github.com/benjamine/jsondiffpatch/blob/0c4323e9bff23ae231f4bff231ceed4df2b48be5/src/filters/arrays.js#L192)