Socket
Socket
Sign inDemoInstall

json-diff

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-diff - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

6

lib/cli.js

@@ -10,3 +10,3 @@ const fs = require('fs')

[
'Usage: json-diff [-vCjfonskKp] first.json second.json',
'Usage: json-diff [-vCjfoxnskKp] first.json second.json',
' <first.json> Old file #var(file1) #required',

@@ -20,3 +20,4 @@ ' <second.json> New file #var(file2) #required',

' --max-elisions COUNT Max number of ...\'s to show in a row in "deltas" mode (before collapsing them) #var(maxElisions)',
' -o, --output-keys KEYS Always print this comma separated keys, with their value, if they are part of an object with any diff #var(outputKeys)',
' -o, --output-keys KEYS Always print this comma separated keys, with their value, if they are part of an object with any diff #var(excludeKeys)',
' -x, --exclude-keys KEYS Exclude these comma separated keys from comparison on both files #var(excludeKeys)',
' -n, --output-new-only Output only the updated and new key/value pairs (without marking them as such). If you need only the diffs from the old file, just exchange the first and second json. #var(outputNewOnly)',

@@ -32,2 +33,3 @@ ' -s, --sort Sort primitive values in arrays before comparing #var(sort)',

options.outputKeys = options.outputKeys ? options.outputKeys.split(',') : []
options.excludeKeys = options.excludeKeys ? options.excludeKeys.split(',') : []

@@ -34,0 +36,0 @@ if (options.verbose) {

@@ -8,2 +8,3 @@ const { SequenceMatcher } = require('difflib')

options.outputKeys = options.outputKeys || []
options.excludeKeys = options.excludeKeys || []
this.options = options

@@ -25,3 +26,3 @@ }

if (!(key in obj2)) {
if (!(key in obj2) && !(this.options.excludeKeys.includes(key))) {
result[`${key}${postfix}`] = value

@@ -37,3 +38,3 @@ score -= 30

if (!(key in obj1)) {
if (!(key in obj1) && !(this.options.excludeKeys.includes(key))) {
result[`${key}${postfix}`] = value

@@ -40,0 +41,0 @@ score -= 30

@@ -9,3 +9,3 @@ {

"description": "JSON diff",
"version": "0.9.1",
"version": "0.10.0",
"homepage": "https://github.com/andreyvit/json-diff",

@@ -12,0 +12,0 @@ "license": "MIT",

@@ -53,2 +53,4 @@ JSON structural diff

-x, --exclude-keys KEYS Exclude these comma separated keys from comparison on both files
-n, --output-new-only Output only the updated and new key/value pairs (without marking them as

@@ -317,2 +319,3 @@ such). If you need only the diffs from the old file, just exchange the

----------
* 0.10.0 Add --exclude-keys
* 0.9.1 Fix bug #88

@@ -319,0 +322,0 @@ * 0.9.0 Add --output-new-only option

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