jq will sort (-S
) the whole file (.
) and compare STDOUT (<()
) with diff
diff <(jq -S . A.json) <(jq -S . B.json)
jq will sort (-S
) the whole file (.
) and compare STDOUT (<()
) with diff
diff <(jq -S . A.json) <(jq -S . B.json)
I've been using you command. But it seems that it does not fully order all the json. I've found this blog. It tells us to use a filter walk.filter
which is documented in the blog. And then you have a sorted json with jq -S -f walk.filter file1.json
You can use:
diff <(jq 'keys' file1.json) <(jq 'keys' file2.json)
This will just give you the list of keys that are different.