Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

How to filter JSON containing any of possible values, using jq

$
0
0

I have the following json fragment:

["FOO": {"name": "Donald","locations": ["Stockholm","London"]    },"BAR": {"name": "Walt","location":  ["Stockholm","Munich"]    },"BAZ": {"name": "Jack","location":  ["Munich","Paris"]    },"BUZ": {"name": "John","location": ["London","Paris"]    },"QUX": {"name": "Mickey"    }]

How would I use jq to filter to all the that have any of Munich or Paris--that is:

["BAR": {"name": "Walt","location":  ["Stockholm","Munich"]    },"BAZ": {"name": "Jack","location":  ["Munich","Paris"]    },"BUZ": {"name": "John","location": ["London","Paris"]    }]

(of course, also excluding those that have no location at all)

It seems like when I use or, I get duplicated output.


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>