gpt4 book ai didi

amazon-web-services - AWS 步骤函数 : check for null

转载 作者:行者123 更新时间:2023-12-04 14:29:47 24 4
gpt4 key购买 nike

Step Function 定义如下:

{
"StartAt": "Decision_Maker",
"States": {
"Decision_Maker":{
"Type": "Choice",
"Choices": [
{
"Variable": "$.body.MyData",
"StringEquals": "null", //that doesn't work :(
"Next": "Run_Task1"
}],
"Default": "Run_Task2"
},
"Run_Task1": {
"Type": "Task",
"Resource": "url_1",
"Next": "Run_Task2"
},
"Run_Task2": {
"Type": "Task",
"Resource": "url_2",
"End": true
}
}
}
基本上它是两个任务之间的选择。
输入数据是这样的:
{
"body": {
"prop1": "value1",
"myData": {
"otherProp": "value"
}
}
}
问题是有时 JSON 中没有 myData。所以输入可能是这样的:
{
"body": {
"prop1": "value1",
"myData": null
}
}
如何检查 myData 是否为空?

最佳答案

截至 2020 年 8 月,Amazon States Language 现在有 isNullisPresent选择规则。 使用这些,您可以 native 检查 null或者在选择状态内的状态输入中存在一个键。
例子:

{ "Variable": "$.possiblyNullValue", "IsNull": true }
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-choice-state.html#amazon-states-language-choice-state-rules

关于amazon-web-services - AWS 步骤函数 : check for null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63039270/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com