I use the deep-diff Node.js library for comparison of two JSONs. There is also pre-filter condition for omitting few fields for comparison. If my pre-filter condition is multiple attributes, how would I specify that? In the given example, the pre-filter attribute is name
. If I want to add one or more attributes, how would I specify that. Thanks in advance.
var diff = require('deep-diff').diff;
var lhs = {
name: 'my object',
description: 'it\'s an object!',
details: {
it: 'has',
an: 'array',
with: ['a', 'few', 'elements']
}
};
var rhs = {
name: 'updated object',
description: 'it\'s not an object!',
details: {
it: 'has',
an: 'array',
with: ['a', 'few', 'more', 'elements', {
than: 'before'
}]
}
};
var differences = diff(lhs, rhs, function(path, key) {
return key === 'name';
});
console.log(differences);