Doing .json file diffs using plain vanilla diff works, but it’s a pain you don’t really need.
Another way of doing .json file diffs follows, add it to .bashrc or whatever shell you’re using and you’ll always carry it with you 😎
Prerequisites:
sudo apt update
sudo apt install jq git-delta -y
For .bashrc:
bashjsondiff() {
if [ "$#" -ne 2 ]; then
echo "Usage: jsondiff "
return 1
fi
#
diff -u --label="$1" --label="$2" \
<(jq -S . "$1") \
<(jq -S . "$2") | delta --side-by-side
}
If you don’t want delta to go full-blown syntax theming the output, you can change the delta --side-by-side to be delta --side-by-side --syntax-theme=none instead.
Tweak to your liking.