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
[]
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
[]
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file json_diff_cli-1.0.1.tar.gz
.
File metadata
- Download URL: json_diff_cli-1.0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d72d2611e0b5ef54006d5afbd363c921c7088b44604442844430dda9752b67c9 |
|
MD5 | 2624dc3c76403ff1ca47331090b853bd |
|
BLAKE2b-256 | 782db294e4d89528d744832780e1c6d513d2fefde7838e9fb8e85f22611d3f7b |
File details
Details for the file json_diff_cli-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: json_diff_cli-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbab532423d24dc9ba1984e61b1c6644ae5cff60581babe677e0efba1011aec |
|
MD5 | 2508fcb403d3a35f30461c51e0651f67 |
|
BLAKE2b-256 | 23d00775a1601a60bf1787ff871b6195e95a1246f29a374ada4c9d80c869956a |