如何根据条件停止管道jq执行?
使用 ActiveCampain 工作流程,我有一个管道,我想在其中根据 jq 命令的输出有条件地执行代码。
例如,如果 .status == "event-created"
,我想执行 !http
和 !jq
命令。
JSON
{
"id":1,
"firstname": "Nj",
"lastname": "Bhanushali",
"email": "[email protected]",
"title":"Call with new lead",
"status":"event-created"
}
代码
"!pipe": [
{
"!jq": ".status"
},
//call this jq if .status == "event-created"
{
"!http": {
"method": "GET",
"path": "/contact/fields"
}
},
{
"!jq": "${piped_content::1}"
},
]
Using ActiveCampain work flows, I have a pipeline in which I want to execute code conditionally based on the output of a jq command.
For example, I want to execute and !http
and !jq
command if .status == "event-created"
.
JSON
{
"id":1,
"firstname": "Nj",
"lastname": "Bhanushali",
"email": "[email protected]",
"title":"Call with new lead",
"status":"event-created"
}
Code
"!pipe": [
{
"!jq": ".status"
},
//call this jq if .status == "event-created"
{
"!http": {
"method": "GET",
"path": "/contact/fields"
}
},
{
"!jq": "${piped_content::1}"
},
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
快速查看文档表明有一个
!switch
“命令”即可使用。注意:
我不知道其中一种情况是否可以接受空哈希。也许你必须使用
null
?也许你必须省略它?如果省略它,也许您必须使用if .status == "event-created" then 0 elseempty end
?如果有效,那将是最干净的解决方案。根据需要进行调整。我不知道我所做的更改后
${piped_content::1}
是否仍然正确。根据需要进行调整。A quick look at the docs suggest there's a
!switch
"command" you can use.Notes:
I don't know if it's acceptable to have an empty hash for one of the cases. Maybe you have to use
null
? Maybe you have to omit it? If you omit it, maybe you have to useif .status == "event-created" then 0 else empty end
? If that works, that would be the cleanest solution. Adjust as necessary.I don't know if
${piped_content::1}
is still correct with the changes I've made. Adjust as necessary.