New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json-difference

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-difference

json diff lib

  • 1.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
decreased by-18.52%
Maintainers
1
Weekly downloads
 
Created
Source

jsondiffer

Total Downloads npm version CI Node.js Package Project Status: Active – The project has reached a stable, usable state and is being actively developed. codecov MIT License

Example

master

Installation

npm install json-difference --save

<script type="module">
  import { getDiff } from 'https://rawgit.com/lukascivil/jsondiffer/master/dist.browser/json-difference.mjs';
</script>

Example

Running example:

npm run example {simple, stress}

Usage

Method:

getDiff(oldStruct, newStruct)

Returns the structural diff between oldStruct and newStruct.

Simple usage:

import { JsonDiffer } from 'json-difference';

const coffee = { color: { color1: 'black', color2: 'brown' }, special: true };
const oil = { color: { color1: 'red', color2: 'blue' }, special2: false };

const jsondifference = new JsonDiffer();
let diff = jsondifference.getDiff(coffee, oil);

console.log(diff);

Output:

{
  "new": {
    "special2": false
  },
  "removed": {
    "special": true
  },
  "edited": [
    {
      "color/color1": {
        "oldvalue": "black",
        "newvalue": "red"
      }
    },
    {
      "color/color2": {
        "oldvalue": "brown",
        "newvalue": "blue"
      }
    }
  ]
}

Keywords

FAQs

Package last updated on 16 Aug 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc