Assuming two json files:a.json
[ {"category": "utils","name": "yq" }, {"category": "utils","name": "yq4" }, {"category": "utils","name": "yip" }, {"category": "utils","name": "jq" }, {"category": "utils","name": "yip-systemd" }, {"category": "utils","name": "system-tools" }]b.json
[ {"category": "utils","name": "jq" }, {"category": "utils","name": "yq" }, {"category": "utils","name": "yip" }, {"category": "utils","name": "yq4" }, {"category": "utils","name": "yip-systemd" }, {"category": "utils","name": "system-tools" }, {"category": "utils","name": "test" }]In order to get the objects in b that are not in a, can run:
jq -n --argfile a a.json --argfile b b.json '$b-$a | .[] | .category +"/" + .name'the result being:
"utils/test"Using jq, how to manage the situation when additional properties are set, having different values"?
For example:a.json
[ {"category": "utils","name": "yq","version": "1" }, {"category": "utils","name": "yq4","version": "1" }, {"category": "utils","name": "yip","version": "1" }, {"category": "utils","name": "jq","version": "1" }, {"category": "utils","name": "yip-systemd","version": "1" }, {"category": "utils","name": "system-tools","version": "1" }]b.json
[ {"category": "utils","name": "jq","version": "2" }, {"category": "utils","name": "yq","version": "2" }, {"category": "utils","name": "yip","version": "2" }, {"category": "utils","name": "yq4","version": "2" }, {"category": "utils","name": "yip-systemd","version": "2" }, {"category": "utils","name": "system-tools","version": "2" }, {"category": "utils","name": "test","version": "2" }]having the result:
"utils/test"