In this post, we will see how to resolve delete from one object those entries matching another object based off string id
Question:
So, given two files with JSON data from the same source type. The JSON objects look something like:file1:
A couple of attempts have been various permutations of the following with accompanying errors:
I’m trying not to have to use a function and I want to accomplish this using
jq
. I’m probably not too far off, but I’m at a loss. Any thoughts?Best Answer:
You could compile a list of IDs from the second file usinginput
, check against it using IN
, and either use del
to delete the matching, or map
to keep those that do not
match:If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review