difference-json
v1.0.6
Published
prompt the diffrence of two json objects
Downloads
35
Readme
Install
Using npm:
npm install difference-json
Usage
Get the difference of arrays:
var diff = require('difference-json');
var result = diff([1,2,3],[1,6,7]);
//result equals:
[{
$set: 6,
$was: 2,
$index: 1
}, {
$set: 7,
$was: 3,
$index: 2
}]
Get the difference of simple json objects:
var diff = require('difference-json');
var result = diff({
name: 'john'
},{
name: 'andre'
});
//result equals:
{
name: {
$was: 'john',
$set: 'andre'
}
}
Get the difference of simple nested json objects:
var diff = require('difference-json');
var result = diff({
role: 'customer',
basket: {
sum: 20
}
},{
role: 'customer',
basket: {
sum: 35
}
});
//result equals:
{
basket: {
sum: {
$set: 35,
$was: 20
}
}
}
Related
- shape-json - Convert json to json with a predefined scheme
- shape-array - Convert array to json object
License
MIT © Andre Stehle