Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 2 KB

readme.md

File metadata and controls

73 lines (52 loc) · 2 KB

Generates differences between two json files on the console in a colored and columnar manner.

Motivation

To find difference between two long json files on the cli itself, instead of downloading files and copy pasting on some website to find the difference. Helpful when comparing production env data with the admin dashboard data during the debugging process.

Installation

pip install json-diff-cli

Quickstart

  • if a key appears in first file but not in second file OR the key appears in second file but not in first file, color of the key changes to red

  • if a value of a specific key is different in both the files, color of that key-value pair changes to green:

Combination of above 2 example

[Example]

Caveats

>>> jdif
usage: jdif [-h] jsonFilePath1 jsonFilePath2
jdif: error: the following arguments are required: jsonFilePath1, jsonFilePath2
Arguments absent: please specify file paths as shown in the example below:
jdif example_1.json example_2.json

>>> jdif /../ /.../
Unable to read file in '\..', please verify the path and filename alongwith the extension

>>> jdif a1.json b1.json 
Invalid json in 'b1.json'

>>> jdif a1.json b1.json
Empty json in 'b1.json'

>>> jdif a1.json b1.json
JSON is same in both the files

order of the keys might change within an object because we are first processing values then modified keys:

suppose if j1.json has:

{
    "key1": true,
    "key3": "abcd"
}

j2.json:

{
    "key4": false,
    "key3": ""
}
>>> jdif j1.json j2.json

[Example]

Features

  • Takes care of unicode, windows1252 characters, so the strings could be in any language or represent a symbol
  • Takes care of long descriptive values or keys
  • Takes care of empty valued strings
  • Instead of dumping into some other file, it displays the differences on the console itself