Reputation: 2807
I am trying to use jq
to remove keys from the first file that exist in the second file.
Given:
a.json:
{"a": 1, "b": 2}
b.json:
{"b": true}
Required contents of diff.json:
{"a": 1}
Question:
What's the jq
syntax to subtract these two JSONs?
Thanks!
Upvotes: 0
Views: 206
Reputation: 50795
We had a very similar question yesterday, my answer to that can be adapted for this case as shown below.
$ jq 'delpaths([input | path(.[])])' a.json b.json > diff.json
$ cat diff.json
{
"a": 1
}
Upvotes: 1