英文:
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
字段对Good
、Average
和Bad
属性进行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
}
]
英文:
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.
Output
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
}
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论