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.7.0 to 0.7.1

5

lib/cli.js

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

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

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

' -f, --full Include the equal sections of the document, not just the deltas #var(full)',
' -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)',
' -s, --sort Sort primitive values in arrays before comparing #var(sort)',

@@ -26,2 +27,4 @@ ' -k, --keys-only Compare only the keys, ignore the differences in values #var(keysOnly)'

options.outputKeys = options.outputKeys ? options.outputKeys.split(',') : []
if (options.verbose) {

@@ -28,0 +31,0 @@ process.stderr.write(`${JSON.stringify(options, null, 2)}\n`)

3

lib/index.js

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

constructor (options) {
options.outputKeys = options.outputKeys || [];
this.options = options

@@ -44,3 +45,3 @@ }

equal = false
} else if (this.options.full) {
} else if (this.options.full || this.options.outputKeys.includes(key)) {
result[key] = value1

@@ -47,0 +48,0 @@ }

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

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

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

@@ -36,15 +36,17 @@ JSON structural diff

Usage: json-diff [-vCjfk] first.json second.json
Usage: json-diff [-vCjfosk] first.json second.json
Arguments:
<first.json> Old file
<second.json> New file
Arguments:
<first.json> Old file
<second.json> New file
General options:
-v, --verbose Output progress info
-C, --[no-]color Colored output
-j, --raw-json Display raw JSON encoding of the diff
-f, --full Include the equal sections of the document, not just the deltas
-k, --keys-only Compare only the keys, ignore the differences in values
-h, --help Display this usage information
General options:
-v, --verbose Output progress info
-C, --[no-]color Colored output
-j, --raw-json Display raw JSON encoding of the diff
-f, --full Include the equal sections of the document, not just the deltas
-o, --output-keys KEYS Always print these [comma separated] keys, with their values, if they are in an object with a diff
-s, --sort Sort primitive values in arrays before comparing
-k, --keys-only Compare only the keys, ignore the differences in values
-h, --help Display this usage information

@@ -90,2 +92,3 @@ In javascript (ES5):

* "full" option to output the entire json tree, not just the deltas
* "outputKeys" option to always output the given keys for an object that has differences
* reasonable test coverage (far from 100%, though)

@@ -274,2 +277,3 @@

----------
* 0.7.1 Add --output-keys option
* 0.7.0 Add --sort option

@@ -276,0 +280,0 @@ * 0.6.3 Fix ticket #68

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