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

How to limit properties of a JSON object given array of property names using JQ?

$
0
0

Assuming I have the following JSON object (which is just an example):

{ "foo": 1, "bar": 2, "baz": 3 }

And the following JSON array (another example):

["foo", "baz"]

How could I use jq to output the following object?

{ "foo": 1, "baz": 3 }

I hate asking this question because I feel certain it has been answered before, but google has failed me and my jq-fu is just not where it needs to be to figure this out.


Viewing all articles
Browse latest Browse all 657

Trending Articles



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