json diff with jq, also: side-by-side output
Websites
There are online resources:
- JSON Diff - Online JSON Compare Diff Finder
- JSON Diff - The semantic JSON compare tool is a bit prettier All similar to each other. I don’t find them intuitive, don’t like copypasting, and privacy/NDAs are important.
CLI
SO thread1 version:
diff <(jq --sort-keys . A.json) <(jq --sort-keys . B.json)
Wrapped it into a function in my .zshrc
:
jdiff() {
diff <(jq --sort-keys . "$1") <(jq --sort-keys . "$2")
}
Side-by-side output
vimdiff
is a thing and does this by default!
Otherwise2 diff has the parameters -y
, and --suppress-common-lines
is useful.
This led to jdiff
’s brother jdiffy
:
jdiffy() {
diff -y --suppress-common-lines <(jq --sort-keys . "$1") <(jq --sort-keys . "$2")
}
Other
git diff --no-index
allows to use git diff without the thing needing to be inside a repo. Used it heavily previously for some of its fancier functions. Say hi to gdiff
:
gdiff() {
git diff --no-index "$1" "$2"
}
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus