Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
[2, 4, 3]我想在像with这样的数组中选择元素 >= 3,jq我该怎么做?
[2, 4, 3]
jq
[{Name:"a", Age:2} ...]}当数组包含对象(例如)时,我找到了答案,select (.Age >= 2)但我不知道如何引用值
[{Name:"a", Age:2} ...]}
select (.Age >= 2)
使用..
.
如果要保留数组结构,可以使用map(select(_)),例如
map(select(_))
jq -n '[2, 4, 3] | map(select(. >= 3))'
如果您只想要这些值,您可以考虑:
jq '.[] | select(. >= 3)' <<< '[2, 4, 3]'