jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.57k stars 1.58k forks source link

Pipe filters into another filter #581

Closed hosinfefer closed 10 years ago

hosinfefer commented 10 years ago

I'm looking to jquery output from our zimbra server and only show folders with a .defaultView == "message" I can run

.subFolders[] .defaultView == "message" and return 'True' on the items I want, but I cannot pipe the True statement into another to pull the paths associated with .defaultView == "message". I tried using | to pipe it into a new filter, however I think since they are in the same sibling then I cannot do that?

You can see an example output at http://pastebin.com/sDFesSxt

Thanks for your help.

wtlangford commented 10 years ago

You want .subFolders[] | select(.defaultView == "message") or .subFolders | map( select(.defaultView == "message")), depending on if you want a stream or an array back. The map variant gives you an array. On Sep 24, 2014 10:51 AM, "hosinfefer" notifications@github.com wrote:

I'm looking to jquery output from our zimbra server and only show folders with a .defaultView == "message" I can run

.subFolders[] .defaultView == "message" and return 'True' on the items I want, but I cannot pipe the True statement into another to pull the paths associated with .defaultView == "message". I tried using | to pipe it into a new filter, however I think since they are in the same sibling then I cannot do that?

You can see an example output at http://pastebin.com/sDFesSxt

Thanks for your help.

— Reply to this email directly or view it on GitHub https://github.com/stedolan/jq/issues/581.