我在 AWS Step Function 中有一个 Choice 状态,它将比较 Input 中数组的长度并决定进入下一个状态。
但是,length()
获取数组长度的函数返回了错误:
{
"error": "States.Runtime",
"cause": "执行状态 'CheckItemsCountState' 时发生错误(在事件 id #18 处输入)。无效路径 '$.Metadata[2].Items.length( )':选择状态的条件路径引用了无效值。”}
选择状态的定义如下:
"CheckItemsCountState":{
"Type": "Choice",
"InputPath": "$",
"OutputPath": "$",
"Default": "NoItemsState",
"Choices":[
{
"Variable": "$.Metadata[2].Items.length()",
"NumericGreaterThan": 0,
"Next": "ProcessState"
}
]
},
该状态连接到返回 JSON 的其他状态。JSON如下:
{
"Metadata": [
{
"foo": "name"
},
{
"Status": "COMPLETED"
},
{
"Items": []
}
]
}
所以我试图获取 in 的长度Items
并Metadata[2]
在值大于 0 时进行比较。
我试图验证$.Metadata[2].Items.length()
这个网站中的 JsonPath ,它返回 0。
我不确定我是否错过了什么。我在 AWS Step Function 的文档或在 jsonpath 中使用函数的示例中找不到任何信息。
我将不胜感激。谢谢!