json-diff-cli
json-diff-cli allows you to diff the JSON of two urls and see what the differences are. This tool can be used for testing purposes or to simply check that things are working.
``
Commands:
help [command...] Provides help for a given command.
exit Exits application.
diff [options]
csv [options]
`
``
jsondiff diff
leftURL: The base URL you would like to compare to.
rightURL: The new/updated URL. The JSON from rightURL will be compared with the leftURL and changes will be printed out to the console.
`
Usage: diff [options]
diffs the json response of two URLs.
Options:
--help output usage information
-o, --output
-f, --failOnDiff return exit code 1 if there is a difference
-x, --diffheaders diff the headers as well as the body
-H, --headers
-i, --ignore
-m, --method
-b, --body Request body (only for POST)
-k, --sortkey
-t, --timeout
`
#### Input
##### leftJSON
`json`
{
"foo": {
"bar": {
"a": true,
"b": "now u see me"
}
}
}
##### rightJSON
`json`
{
"foo": {
"bar": {
"a": false,
"c": "now you dont"
}
}
}
#### Output
``
key left right diff
--------- ------------ ------------ -------
foo.bar.c undefined now you dont added
foo.bar.b now u see me undefined deleted
foo.bar.a true false updated
``
jsondiff csv [options]
input: Path to the input file (CSV format).
`
Usage: csv [options]
diffs all urls in a csv file
Options:
--help output usage information
-o, --output
-s, --sleep
-x, --diffheaders diff the headers as well as the body
-t, --timeout
`
#### Input
The first line in the CSV file must have the following headers. You may chose to omit any of them except for ur1, and url2
``
url1, url2, method, headers, body, sortKey, ignore
ur1: Left URL
ur2: Right URL
method: Request method, defaults to GET [optional]
headers: Headers included in the request, pipe delimited. (|)
body: POST body, JSON
sortKeys: key to sort any arrays by.
ignore: keys to ignore. Pipe delimted. (|)
expectedStatusCode: Expected status code (defaults to 200)
`csv`
url1,url2
https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json
https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json
https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json
#### Output
##### csv
``
id,left url,left response time,right url,right response time,key,left value,right value,difference,status
0,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,1197,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,675,foo.bar.c,undefined,now you dont,added,fail
0,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,1197,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,675,foo.bar.b,now u see me,undefined,deleted,fail
0,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,1197,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,675,foo.bar.a,true,none,updated,fail
1,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,481,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,533,foo.bar.c,undefined,now you dont,added,fail
1,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,481,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,533,foo.bar.b,now u see me,undefined,deleted,fail
1,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,481,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,533,foo.bar.a,true,none,updated,fail
2,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,396,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,386,foo.bar.c,undefined,now you dont,added,fail
2,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,396,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,386,foo.bar.b,now u see me,undefined,deleted,fail
2,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json,396,https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json,386,foo.bar.a,true,none,updated,fail
##### console
`
https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json vs https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json
key left right diff
--------- ------------ ------------ -------
foo.bar.c undefined now you dont added
foo.bar.b now u see me undefined deleted
foo.bar.a true false updated
https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json vs https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json
key left right diff
--------- ------------ ------------ -------
foo.bar.c undefined now you dont added
foo.bar.b now u see me undefined deleted
foo.bar.a true false updated
https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/a.json vs https://gist.githubusercontent.com/nahtnam/920171eeef10e911a6ee7698d9c226ae/raw/bdd86427b8c807e149251d4737d2886620f7fcdc/b.json
key left right diff
--------- ------------ ------------ -------
foo.bar.c undefined now you dont added
foo.bar.b now u see me undefined deleted
foo.bar.a true false updated
``