我有以下 json 输入到逻辑应用程序
[ {
"ACTIVITYID": "0002868073",
"STATUS": "Released",
"COMMENTS":[
{
"COMMENT":"Comment_1"
},
{
"COMMENT":"Comment_2"
}
]
},{
"ACTIVITYID": "0002868071",
"STATUS": "Approved",
"COMMENTS":[
]{ "COMMENT":"评论_3" }, { "COMMENT":"评论_4" } ] } ]
我想要类似的输出
0002868073 已发表评论_1 评论_2
0002868071 已批准评论_3 评论_4
这是我的逻辑应用程序代码视图
{ “定义”: { “$schema”:“https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#”, “行动”:{ “For_each_-ActivityLoop”:{ “行动”:{ “追加到字符串变量_2”:{ “输入”:{ "name": "最终评论", “值”:“@variables('AppendInnerComment')” }, “追赶”: { “For_each-CommentsLoop”:[ “成功了” ] }, “类型”:“追加到字符串变量” }, “For_each-CommentsLoop”:{ “行动”:{ “追加到字符串变量”:{ “输入”:{ "name": "内部评论", "value": "@items('For_each-CommentsLoop')['COMMENT']" }, “追赶”: {}, “类型”:“追加到字符串变量” }, “追加到字符串变量_3”:{ “输入”:{ "name": "附加内部注释", “值”:“@variables('InnerComment')” }, “追赶”: { “追加到字符串变量”:[ “成功了” ] }, “类型”:“追加到字符串变量” } }, "foreach": "@items('For_each-ActivityLoop')['COMMENTS']", “追赶”: {}, “类型”:“foreach” }, “设置变量2”:{ “输入”:{ "name": "最终输出", "value": "@{items('For_each-ActivityLoop')['ACTIVITYID']}@{items('For_each-ActivityLoop')['STATUS']}@{variables('FinalComment')} ” }, “追赶”: { “追加到字符串变量_2”:[ “成功了” ] }, “类型”:“设置变量” } }, "foreach": "@body('Parse_JSON')", “追赶”: { “解析_JSON”:[ “成功了” ] }, “类型”:“foreach” }, “Initialize_FinalComment”:{ “输入”:{ “变量”:[ { "name": "最终评论", “类型”:“字符串” } ] }, “追赶”: { "Initialize_variable-AppendInnerComment": [ “成功了” ] }, "type": "初始化变量" }, “初始化_最终输出”:{ “输入”:{ “变量”:[ { "name": "最终输出", “类型”:“字符串” } ] }, “追赶”: { “Initialize_FinalComment”:[ “成功了” ] }, "type": "初始化变量" }, “Initialize_InnerComment”:{ “输入”:{ “变量”:[ { "name": "内部评论", “类型”:“字符串” } ] }, “追赶”: { “初始化_最终输出”:[ “成功了” ] }, "type": "初始化变量" }, “Initialize_variable-_AppendInnerComment”:{ “输入”:{ “变量”:[ { "name": "附加内部注释", “类型”:“字符串” } ] }, “追赶”: {}, "type": "初始化变量" }, “解析_JSON”:{ “输入”:{ "内容": "@triggerBody()", “架构”:{ “项目”: { “特性”: { “活动ID”:{ “类型”:“字符串” }, “评论”: { “项目”: { “特性”: { “评论”: { “类型”:“字符串” } }, “必需的”: [ “评论” ], “类型”:“对象” }, “类型”:“数组” }, “SAP用户ID”:{ “类型”:“字符串” }, “地位”: { “类型”:“字符串” } }, “必需的”: [ “活动ID”, “地位”, “SAP用户ID”, “评论” ], “类型”:“对象” }, “类型”:“数组” } }, “追赶”: { “初始化_InnerComment”:[ “成功了” ] }, “类型”:“ParseJson” } }, "内容版本": "1.0.0.0", “输出”:{}, “参数”: {}, “触发”:{ “手动的”: { “输入”:{ “方法”:“发布”, “架构”:{ “项目”: { “特性”: { “活动ID”:{ “类型”:“字符串” }, “评论”: { “项目”: { “特性”: { “评论”: { “类型”:“字符串” } }, “必需的”: [ “评论” ], “类型”:“对象” }, “类型”:“数组” }, “SAP用户ID”:{ “类型”:“字符串” }, “地位”: { “类型”:“字符串” } }, “必需的”: [ “活动ID”, “地位”, “SAP用户ID”, “评论” ], “类型”:“对象” }, "“类型”:“� 75e1 ��组”\n"} }, “种类”:“http”, “类型”:“请求” } } }, “参数”: {} }
但是,我得到了输出
0002868073 已发表评论_1 评论_1 评论_2
0002868071 已批准评论_1Comment_1Comment_2Comment_1Comment_1Comment_2Comment_1Comment_2Comment_3Comment_1Comment_2Comment_3Comment_4
请提供建议以获得想要的结果。
我使用了以下工作流程来获得所需的输出。
concat(items('For_each')?['ACTIVITYID'], ' ', items('For_each')?['STATUS'], ' ', items('For_each')?['COMMENTS'][0]['COMMENT'], ' ',items('For_each')?['COMMENTS'][1]['COMMENT'])
代码-
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@variables('Output')",
"runAfter": {
"For_each": [
"Succeeded"
]
},
"type": "Compose"
},
"For_each": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "Output",
"value": "@{concat(items('For_each')?['ACTIVITYID'], ' ', items('For_each')?['STATUS'], ' ', items('For_each')?['COMMENTS'][0]['COMMENT'], ' ',items('For_each')?['COMMENTS'][1]['COMMENT'])} "
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"foreach": "@variables('Input')",
"runAfter": {
"Output": [
"Succeeded"
]
},
"runtimeConfiguration": {
"concurrency": {
"repetitions": 1
}
},
"type": "Foreach"
},
"Input": {
"inputs": {
"variables": [
{
"name": "Input",
"type": "array",
"value": [
{
"ACTIVITYID": "0002868073",
"COMMENTS": [
{
"COMMENT": "Comment_1"
},
{
"COMMENT": "Comment_2"
}
],
"STATUS": "Released"
},
{
"ACTIVITYID": "0002868071",
"COMMENTS": [
{
"COMMENT": "Comment_3"
},
{
"COMMENT": "Comment_4"
}
],
"STATUS": "Approved"
}
]
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Output": {
"inputs": {
"variables": [
{
"name": "Output",
"type": "string"
}
]
},
"runAfter": {
"Input": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
输出-