如何 select 仅包含包含多于 N 个元素的数组的对象
how to select only objects that contain an array with more than N elements
仅捕获以下数组中的第二个对象的正确 JMESPath 表达式是什么(因为它的 topics
数组中有超过 2 个对象):
[{
"topics": [
"just one"
]
},
{
"topics": [
"first",
"second",
"third"
]
}
]
我要吐出来
{
"topics": [
"first",
"second",
"third"
]
}
我试过 [? length(topics) > 2]
但 jp
抱怨:
SyntaxError: Invalid token: tNumber
[? length(topics) > 2]
^
对于输入:
[{
"topics": [
"just one"
]
},
{
"topics": [
"first",
"second",
"third"
]
}
]
使用 jmesExpression:
[?length(topics)>'2']
获取输出:
[
{
"topics": [
"first",
"second",
"third"
]
}
]
仅捕获以下数组中的第二个对象的正确 JMESPath 表达式是什么(因为它的 topics
数组中有超过 2 个对象):
[{
"topics": [
"just one"
]
},
{
"topics": [
"first",
"second",
"third"
]
}
]
我要吐出来
{
"topics": [
"first",
"second",
"third"
]
}
我试过 [? length(topics) > 2]
但 jp
抱怨:
SyntaxError: Invalid token: tNumber
[? length(topics) > 2]
^
对于输入:
[{
"topics": [
"just one"
]
},
{
"topics": [
"first",
"second",
"third"
]
}
]
使用 jmesExpression:
[?length(topics)>'2']
获取输出:
[
{
"topics": [
"first",
"second",
"third"
]
}
]