Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
compare two JSONs with jq #json #jq
Copy link

theArtechnology commented Dec 8, 2020

How to compare by key ?

Copy link

delrioe commented Mar 2, 2021

You can use: diff <(jq 'keys' file1.json) <(jq 'keys' file2.json)
This will just give you the list of keys that are different.

Copy link

briner commented Feb 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment