0.0.15 • Published 7 years ago
json-compare v0.0.15
json-match
NOTE: Currently does not support arrays
About
Compare two json object for matching deep keys, also supports regular-expression.
usage:
npm install json-compare
import compare from 'json-compare' // es6
// OR
const compare = require('json-compare') // good old es5
const source = {
name: "Dave Amit",
hobby: {
game: 'The Division'
},
country: 'India',
};
const test = {
name: /[a-zA-Z ]+/,
hobby: {
game: /Division/,
},
country: 'india',
};
const result = compare(source, test);
// Result will be something like:
{
regExMatch: 2, // Because it matched 2 regular expressions
exactMatch: 0,
fuzzyMatch: 1, // Because India to india match
matchCount: 3, // Total keys matched
mismatchCount: 0,
unmatchedCount: 0,
match: true,
isExactMatch: false, // Because of fuzzyMatch
}