alu-json-diff

0.0.9 • Public • Published

alu-json-diff

Use the command line to compare two folders with the same directory structure and output their differences

If used alone, you can compare two json objects and output the difference (added, removed, edited)

Installation

npm install -g alu-json-diff

Usage

Cli

alu-json-diff oldSourceDirPath newSourceDirPath -o ./dist

Simple usage:

import { diff } from "alu-json-diff";

const struct1 = {
  a: 1,
  b: [{ c1: [{ c3: { c5: [1, 2, { c6: 3 }] } }, { c4: 6 }] }, { c2: 2 }],
};
const struct2 = {
  a: 11,
  b: [{ c1: [{ c3: { c5: [1, 2, { c6: 4 }] } }, { c4: 6 }] }, { c2: 2 }],
};

let result = diff(struct1, struct2);
console.log(result);
//   {
//      edited: [
//        ['a', 1, 11],
//        ['b[0]/c1[0]/c3/c5[2]/c6', 3, 4]
//      ],
//      added: [],
//      removed: []
//    }

Readme

Keywords

Package Sidebar

Install

npm i alu-json-diff

Weekly Downloads

1

Version

0.0.9

License

none

Unpacked Size

7.89 kB

Total Files

6

Last publish

Collaborators

  • kkxiao