GithubHelp home page GithubHelp logo

vspaz / jsondiff Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 121 KB

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.

Python 95.26% Makefile 4.74%
jsondiff jsondiffviewer comparison-tool diff filter json-compare json-comparison precision regex tolerance

jsondiff's Introduction

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 [email protected]: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 [email protected]:vspaz/jsondiff.git
cd jsondiff
pip install -r requirements/dev.txt
make test

jsondiff's People

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.