【发布时间】:2016-03-09 23:40:37
【问题描述】:
所以我有一个如下的 JSON blob:
[
{
'id': 'something',
'isSparse': true
},
...
]
如何编写一个jq 命令来过滤掉这个 JSON blob 并打印出数组中所有具有 isSparse == true 的条目的 ID?
我尝试了以下方法:
cat <blob> | jq -c '.[] | select(.operational | contains("true"))'
但是得到以下,因为显然true 是一个布尔值而不是一个字符串:
jq: error: boolean and string cannot have their containment checked.
【问题讨论】: