Socket
Book a DemoInstallSign in
Socket

difference-json

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

difference-json

prompt the diffrence of two json objects

1.0.6
latest
Source
npmnpm
Version published
Weekly downloads
9
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

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
    }
  }
}
  • shape-json - Convert json to json with a predefined scheme
  • shape-array - Convert array to json object

License

MIT © Andre Stehle

Keywords

json

FAQs

Package last updated on 06 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.