/json-compare

Compares the structure of two JSON values

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

json-compare

Compares two JSON documents by structure. Finds elements in the json document in FILE2 that are not contained in the json document in FILE1.

If FILE2 is equal to FILE1 or a subset of FILE1, then no diff will be returned.

Installation

Use the stack build tool.

git clone https://github.com/TimoFreiberg/json-compare.git
cd json-compare
stack install

Usage

json-compare expected.json actual.json

TODO

Add flags to modify verbosity.

Examples

$ cat expected.json
{
  "foo": "bar",
  "baz": 42,
  "quux": [
    1,
    2
  ]
}
$ cat actual.json
{
  "notThere": "doesn't matter",
  "foo": 42,
  "baz": "bar",
  "quux": {
    "x": [
      1
    ]
  }
}
$ json-compare expected.json actual.json

No key "notThere"
  Found at path: $.notThere
Wrong type, expected: String, actual: Number
  Found at path: $.foo
Wrong type, expected: Number, actual: String
  Found at path: $.baz
Wrong type, expected: Array, actual: Object
  Found at path: $.quux