将来自不同节点的同名值合并为单个值数组的逻辑应用

huangapple go评论50阅读模式
英文:

LogicApp Same Name Values from different Nodes into single array of values

问题

我有一个解析JSON的步骤,它输出了这种结构

[
  {
    "Value": "Sample Value 1"
  },
  {
    "Value": "Sample Value 2"
  }
]

我想要将以下结构转换为

[
"Sample Value 1",
"Sample Value 2"
]

提前感谢。

英文:

I have a parse JSON step which outputs this sort of structure

[
  {
    "Value": "Sample Value 1"
  },
  {
    "Value": "Sample Value 2"
  }
]

I would like to transform the following structure

[
"Sample Value 1",
"Sample Value 2"
]

Thanks in advance

答案1

得分: 1

你需要循环遍历原始数组,并将每个value属性的值添加到一个线性字符串数组中。

这个流程展示了基本步骤...

首先,我创建了一个新的类型为Array的变量,用来存储你的原始数据。

接下来,我初始化了另一个变量,它将保存输出的结果。在初始化时,它没有任何值。

最后,使用一个For each操作,我循环遍历原始数组,在其中有一个Append to array variable步骤,它将value属性的值添加到Simple Array变量中。*Value字段中的表达式是...

item()?['value']

...这将检索每个项目的值并相应地追加它。

这是最终结果...

一点需要注意的是,如果你希望简单数组的顺序与原始数组的值相同,你需要在For each步骤的设置中打开并发性,将其设置为1

英文:

You need to loop over the original array and the value of add each value property to a linear string based array.

This flows shows you the basic steps ...

将来自不同节点的同名值合并为单个值数组的逻辑应用

Firstly, I created a new variable of type Array that stored your original data.

Next, I initialised another variable that will hold the results of the output. When initialised, it was with no value.

Finally, using a For each action, I loop over the original array and within that, there's an Append to array variable step which adds in the value of the value property for each item to the Simple Array variable. The expression in the *Value field is ...

item()?['value']

... that will retrieve the value for each item and append it accordingly.

This is the end result ...

将来自不同节点的同名值合并为单个值数组的逻辑应用

One thing to note is, if you want the simple array to be in the same order as the original array values, you need to go to the settings on the For each step and turn concurrency on to equals 1.

将来自不同节点的同名值合并为单个值数组的逻辑应用

huangapple
  • 本文由 发表于 2023年2月8日 21:50:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75386765.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定