jq will sort (-S
) the whole file (.
) and compare STDOUT (<()
) with diff
diff <(jq -S . A.json) <(jq -S . B.json)
Python json.tool
can sort keys and format the json as well
diff <(python -m json.tool --sort-keys carting.avsc) <(python -m json.tool --sort-keys carting7.avsc)
https://docs.python.org/3/library/json.html#json-commandline