A lightweight npm package that takes two JSON objects and produces a human-friendly diff report.
npm i jsoncomparizer
npm install jsoncomparizer
const { diff } = require('jsoncomparizer');
const obj1 = { name: "Alice", age: 25 };
const obj2 = { name: "Alice", age: 26, city: "Wonderland" };
console.log(diff(obj1, obj2));
const { diff } = require('jsoncomparizer');
const chalk = require('chalk');
const obj1 = { name: "Alice", age: 25 };
const obj2 = { name: "Alice", age: 26, city: "Wonderland" };
const options = {
// the user-provided name that will be formatted with magenta
// You can override styling like this:
// added: text => chalk.bgGreen.black(text)
// removed: text => chalk.bgRed.white(text)
// changed: text => chalk.bgCyanBright.black(text)
// path: text => chalk.underline.cyan(text)
};
console.log(diff(obj1, obj2, options));
Note : Use Chalk (4.1.2) for active options.
npm i chalk@4.1.2
If you have any feedback, please reach out to us at thebradredd@gmail.com