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

Using jq, how can I limit values based on a key

$
0
0

For an input file that looks like this:

{"employees": [    {"number": "101","tags": [        {"value": "yes","key": "management"        },        {"value": "joe","key": "login"        },        {"value": "joe blogs","key": "name"        }      ]    },    {"number": "102","tags": [        {"value": "no","key": "management"        },        {"value": "jane","key": "login"        },        {"value": "jane doe","key": "name"        }      ]    },    {"number": "103","tags": [        {"value": "no","key": "management"        },        {"value": "john","key": "login"        },        {"value": "john doe","key": "name"        }      ]    }  ]}

... I'd like to get details for all non-management employees so that the desired output looks like this:

{"number": "102","name": "jane doe","login": "jane"}{"number": "103","name": "john doe","login": "john"}

I can't figure out how to limit results based on a key without selecting that key (in this case "management")


Viewing all articles
Browse latest Browse all 657

Trending Articles



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