在Azure Logic App消耗中合并数组项

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

Combine array items in Azure Logic App Consumption

问题

我有一个包含对象数组的http操作输出,看起来像这样:

{
"Id": 1,
"Good": 0,
"Average": 0,
"Bad": 1
},
{
"Id": 2,
"Good": 1,
"Average": 0,
"Bad": 0
},
{
"Id": 1,
"Good": 0,
"Average": 1,
"Bad": 0
},
{
"Id": 3,
"Good": 0,
"Average": 0,
"Bad": 1
},
{
"Id": 1,
"Good": 0,
"Average": 1,
"Bad": 0
}

我该如何在不使用内联JavaScript的情况下,使用dataoperation操作将它们合并以获得以下结果?基本上我需要对记录的值进行求和,并按ID合并。

{
"Id": 1,
"Good": 0,
"Average": 2,
"Bad": 1
},
{
"Id": 2,
"Good": 1,
"Average": 0,
"Bad": 0
},
{
"Id": 3,
"Good": 0,
"Average": 1,
"Bad": 0
}
英文:

I have an output of http action which contains an array of objects and looks like this:

[
{
"Id":1,
"Good":0,
"Average":0,
"Bad":1
},
{
"Id":2,
"Good":1,
"Average":0,
"Bad":0
},
{
"Id":1,
"Good":0,
"Average":1,
"Bad":0
},
{
"Id":3,
"Good":0,
"Average":0,
"Bad":1
},
{
"Id":1,
"Good":0,
"Average":1,
"Bad":0
},
]

How can i combine them to get this result without using inline javascript, using dataoperation action? Basically i need to sum records` values, and combine by ID

[
{
"Id":1,
"Good":0,
"Average":2,
"Bad":1
},
{
"Id":2,
"Good":1,
"Average":0,
"Bad":0
},
{
"Id":3,
"Good":0,
"Average":1,
"Bad":0
}
]

答案1

得分: 1

这是如何通过使用高级数据操作连接器中的聚合操作来实现您所需的示例。

这是配置为通过Id字段对GoodAverageBad属性进行SUM的数据。

输出

结果

[
  {
    "Id": 1,
    "Good": 0,
    "Average": 2,
    "Bad": 1
  },
  {
    "Id": 2,
    "Good": 1,
    "Average": 0,
    "Bad": 0
  },
  {
    "Id": 3,
    "Good": 0,
    "Average": 0,
    "Bad": 1
  }
]

在Azure Logic App消耗中合并数组项

在Azure Logic App消耗中合并数组项

英文:

This is an example of how to achieve what you're wanting by using the Aggregate operation in the Advanced Data Operations connector.

This is your data configured to SUM the Good, Average and Bad properties by the Id field.

在Azure Logic App消耗中合并数组项

Output

在Azure Logic App消耗中合并数组项

Result

[
  {
    "Id": 1,
    "Good": 0,
    "Average": 2,
    "Bad": 1
  },
  {
    "Id": 2,
    "Good": 1,
    "Average": 0,
    "Bad": 0
  },
  {
    "Id": 3,
    "Good": 0,
    "Average": 0,
    "Bad": 1
  }
]

huangapple
  • 本文由 发表于 2023年7月14日 00:48:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681684.html
匿名

发表评论

匿名网友

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

确定