Skip to main content

To display json differences on CLI

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json_diff_cli-1.0.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

json_diff_cli-1.0.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file json_diff_cli-1.0.2.tar.gz.

File metadata

  • Download URL: json_diff_cli-1.0.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for json_diff_cli-1.0.2.tar.gz
Algorithm Hash digest
SHA256 23cb8c81b4ce8115f36131ebbb56e1f1a8f0cdf11da3230cf394f812a5d79f84
MD5 578a95ae92fcad46b373977e51cea760
BLAKE2b-256 84f4244cbb5da2c70063b291712b2bbe17047f4354d4c834bf391b1b31b7a836

See more details on using hashes here.

File details

Details for the file json_diff_cli-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for json_diff_cli-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 222dc30a64d518bcc102a081701a73449dcf3b4a9080aac146e00dafd007714d
MD5 c8e56a154fa8870fd1fb178e4c22c178
BLAKE2b-256 a19affdf9737bf7d064d0984c043a57d3c067a5640e1d8a44a483ad607764b31

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page