在LogicApp中更新Json数组 [英] Updating Json Array in LogicApp

查看:65
本文介绍了在LogicApp中更新Json数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在逻辑应用程序中更新一些JSON.这是我的JSON.

I am trying to update some JSON in a logic app. Here is my JSON.

{
  "headers": [
    {
      "count": 0,
      "lookup": "PSI"
    },
    {
      "count": 0,
      "lookup": "Clean"
    }
  ]
}

在for each循环中,我尝试更新特定标头数组元素的属性 count .

In a for each loop, I am trying to update the property count of a specific header array element.

这是我正在做的财产.

@setproperty(variables('colObj'),'headers',setproperty(items('For_each'),'count',1))

当前,setproperty仅返回数组的一个元素,而不返回整个数组.

Currently, the setproperty only returns one element of the array and not the entire array.

我需要set属性来返回headers数组的所有元素并更新当前foreach项的count属性.

I need the set property to return all elements of the headers array and to update the count property for the current foreach item.

有人知道如何在逻辑应用程序中执行此操作吗?

Does anyone know how to do this in a logic app?

推荐答案

实际上,我们已经知道要在子对象中设置child属性,而应使用嵌套的 setProperty()调用.而且 items('For_each')不能使json数据的子部分保持安静,就像 variables('colObj')['headers'] [0] 一样.而且,如果您尝试再添加一个嵌套的 setProperty(),它会说该数组不是一个对象,那么您的方式将只会得到一个子数组对象.

Actually, we already know to set the child property in a child object, use a nested setProperty() call instead. And the items('For_each') is not quiet the child part of json data, it's like variables('colObj')['headers'][0]. And if you try to add one more nested setProperty(), it will say the array is not a object then your way will only get one child array object.

因此,如果要获取完整的json对象,则必须添加一些要实现的操作.也许您可以参考我的流程.

So if you want to get the complete json object you will have to add some actions to implement. Maybe you could refer to my flow.

我使用Parse_json设置json数据,它应该是您的 variables('colObj'),一个空对象变量,一个数组变量.

I use a Parse_json to set the json data it should be your variables('colObj'), one null object variable , one array variable.

在For_each中使用 setProperty(body('Parse_JSON'),'headers',setProperty(items('For_each'),'count',34))设置结果对象,然后附加它到阵列.在For_each操作之后,初始化一个新对象以获取所需的对象,并使用 setProperty(body('Parse_JSON'),'headers',variables('middle'))进行设置.

In the For_each set the result object with setProperty(body('Parse_JSON'),'headers',setProperty(items('For_each'),'count',34)) then append it to the array. After the For_each action init a new object to get the object you want and set it with setProperty(body('Parse_JSON'),'headers',variables('middle')).

这是运行详细信息.

这篇关于在LogicApp中更新Json数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆