1.0.4 • Published 3 years ago

json-differences v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

JSON Differences

It finds out the differences between two JSONs

Installation

npm install json-differences

Usage

In JS

var JSONDifferences = require("json-differences");

var jsonDiffer = new JSONDifferences.default();

var _old = {
    'id': 15,
    'boo': 'baa',
    'laa': 'lii'
};
var _new = {
    'id': 15,
    'boo': 'bee',
    'jaa': 'joo'
};

var diff = jsonDiffer.getJsonDiff(_old, _new);

console.log(diff);

in TS

import JsonDiffer from 'json-differences';

const jsonDiffer = new JsonDiffer();

const _old = {
    'id': 15,
    'boo': 'baa',
    'laa': 'lii'
};

const _new = {
    'id': 15,
    'boo': 'bee',
    'jaa': 'joo'
};

const diff = jsonDiffer.getJsonDiff(_old , _new);

console.log(diff);

Output

{
  new: {
    jaa: 'joo'
  },
  updated: {
    boo: {old: 'baa', new: 'bee' } 
  },
  deleted: {
    laa: 'lii' 
  }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago