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.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: json_diff_cli-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 232058191a6eee13318996384befd13806904bb1141c64b9ce7b4e600094c7c2
MD5 ff6b580045e47629fd24c89ca7041737
BLAKE2b-256 5fe6cc2c02d7b2775eadba0dfc7fed40828ddff7b52d2e86dec4104af7373afd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for json_diff_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f401f3481fa20e5f63a91e1e8c13cc51199236167912f426057cb3123b343a38
MD5 7ab90b05a47ca8d49302157575623d8d
BLAKE2b-256 6d37e4714f8bfcb01978a34205fb1581ffd4e474b212a5c76478930698ded6da

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