Skip to content

jsondiff is a json diff utility. It can compare two JSON files, using strings, prefixes, or regex to filter required/optional fields, and apply relative or absolute precision tolerance per each numeric field or globally; prints the diff between 2 json files. It can optionally accept a config with required or optional fields.

vspaz/jsondiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsondiff

yet another jsondiff utility helpful for data analysis.

unlike other json diff utilities:

  • it's possible to skip the fields that you are not interesting for analysis.
  • one can choose only required fields
  • the jsondiff utility compares numeric values using relative or absolute precision tolerance e.g. 1e-03 or 0.001, which can be set globally or per field.
  • it's possible to use field prefixes or regexes to filter out fields.
  • there's an optional config (see below) when dealing with a large number of fields.
  • jsondiff requires no 3d party modules.

NOTE: there's also an experimental WIP version implemented in C & Cython.

install

git clone git@github.com:vspaz/jsondiff.git
cd jsondiff
python3 setup.py install

config (optional)

{
  "required": [],
  "skipped": [
    "barbaz"
  ],
  "tolerance": {
    "default": 1e-09,
    "fields": {
      "foo": 0.01,
      "baz": 0.1
    }
  }
}
jsondiff -f1 tests/data/file_1.json -f2 tests/data/file_2.json -c tests/data/config.json  # -> {}, as field "barbaz" is skipped in the config.

or

jsondiff -f1 tests/data/file_1.json -f2 tests/data/file_2.json  #  -> {'baz': {'barbaz': [90, 80]}}  # no fields are skipped

run tests

git clone git@github.com:vspaz/jsondiff.git
cd jsondiff
pip install -r requirements/dev.txt
make test

About

jsondiff is a json diff utility. It can compare two JSON files, using strings, prefixes, or regex to filter required/optional fields, and apply relative or absolute precision tolerance per each numeric field or globally; prints the diff between 2 json files. It can optionally accept a config with required or optional fields.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published