json JQ:选择多个条件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33057420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 18:05:05  来源:igfitidea点击:

JQ: Select multiple conditions

jsonjq

提问by Andrei Colta

I have a json and at the moment using select to get only the data which match one condition, I need to filter based on more conditions.

我有一个 json,目前使用 select 只获取匹配一个条件的数据,我需要根据更多条件进行过滤。

For e.g:

例如:

.[] | select((.processedBarsVolume <= 5) && .processedBars > 0)

How I can do this ?

我怎么能做到这一点?

回答by Hans Z.

jqsupports the normal Boolean operators and/or/not, so it would look like:

jq支持普通的布尔运算符和/或/不,所以它看起来像:

.[] | select((.processedBarsVolume <= 5) and .processedBars > 0)