如何将Azure Logic App中for_each循环的输出合并到单个平面数组中? [英] How can I merge the outputs from a For_Each loop in an Azure Logic App to a single flat array?
本文介绍了如何将Azure Logic App中for_each循环的输出合并到单个平面数组中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
For_Each
循环,它调用另一个嵌套的Logic App。每次迭代嵌套的Logic Apps的结果是一个包含字符串数组的JSON对象,如下所示:
{
"Results": ["string a", "string b"]
}
因此,父Logic App中的for_each循环的输出如下所示:
[
{"Results": ["string a", "string b"]},
{"Results": ["string c", "string d"]}
]
我想将所有这些字符串放到一个平面列表中,以便传递给另一个操作。
如何才能做到这一点?是否可以使用工作流定义语言和内置函数,或者我是否需要使用外部函数(在服务中或Azure函数中)?
推荐答案
有一个更简单的解决方案,即使用数组变量。 在顶层,在for Each循环之外,使用InitializeVariable操作声明一个变量:
"Initialize_Items_variable": {
"inputs": {
"variables": [
{
"name": "Items",
"type": "Array",
"value": []
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
在for Each中,使用AppendToArrayVariable操作。您可以追加刚才调用的嵌套逻辑App的响应对象。
"Append_to_Items_variable": {
"inputs": {
"name": "Items",
"value": "@body('Nested_Logic_App_Response')"
},
"runAfter": {
},
"type": "AppendToArrayVariable"
}
希望它能有所帮助。
这篇关于如何将Azure Logic App中for_each循环的输出合并到单个平面数组中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文