json-diff-ext

1.0.1 • Public • Published

JSON structural diff

Does exactly what you think it does:

Installation

npm install -g json-diff-ext

Contribution policy

  1. This project is maintained thanks to your contributions! Please send pull requests.

  2. I will merge any pull request that adds something useful, does not break existing things, has reasonable code quality and provides/updates tests where appropriate.

  3. Anyone who gets a significant pull request merged gets commit access to the repository.

Usage

Simple:

json-diff-ext a.json b.json

Detailed:

% json-diff-ext --help
Usage: json-diff-ext [-vjCk] first.json second.json

Arguments:
  first.json            Old file
  second.json           New file

General options:
  -v, --verbose         Output progress info
  -C, --[no-]color      Colored output
  -j, --raw-json        Display raw JSON encoding of the diff
  -k, --keys-only       Compare only the keys, ignore the differences in values
  -h, --help            Display this usage information

In javascript (ES5):

var jsonDiff = require('json-diff-ext')

console.log(jsonDiff.diffString({ foo: 'bar' }, { foo: 'baz' }));

// Output:
//  {
// -  foo: "bar"
// +  foo: "baz"
//  }

console.log(jsonDiff.diff({ foo: 'bar' }, { foo: 'baz' }));

// Output:
// { foo: { __old: 'bar', __new: 'baz' } }

In javascript (ES6+):

import { diffString, diff } from 'json-diff-ext';

console.log(diffString({ foo: 'bar' }, { foo: 'baz' }));
console.log(diff({ foo: 'bar' }, { foo: 'baz' }));

Features

  • colorized, diff-like output
  • fuzzy matching of modified array elements (when array elements are object hierarchies)
  • compare only the json structure (keys), ignoring the values
  • reasonable test coverage (far from 100%, though)

Readme

Keywords

none

Package Sidebar

Install

npm i json-diff-ext

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

26.1 kB

Total Files

10

Last publish

Collaborators

  • kensol23