jsoncomparizer

1.1.5 • Public • Published

Jsoncomparizer

A lightweight npm package that takes two JSON objects and produces a human-friendly diff report.

Installation

 npm i jsoncomparizer
 npm install jsoncomparizer

Package usage

const { diff } = require('jsoncomparizer');

const obj1 = { name: "Alice", age: 25 };
const obj2 = { name: "Alice", age: 26, city: "Wonderland" };

console.log(diff(obj1, obj2));

options argument

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

Output

output1

License

ISC

Feedback

If you have any feedback, please reach out to us at thebradredd@gmail.com

Package Sidebar

Install

npm i jsoncomparizer

Weekly Downloads

5

Version

1.1.5

License

ISC

Unpacked Size

18.7 kB

Total Files

4

Last publish

Collaborators

  • chamods