如何在逻辑应用程序中使用json解析删除json元素?

时间:2019-11-11 12:22:26

标签: json azure azure-logic-apps

输入json-

{
    "data": {
        "Testresults": [
            {
                "mydata": {
                    "id": "111",
                    "uri": "url",
                    "type": "demo"
                },
                "name": "",
                "address": "",

在侧面Parse Json模式中添加了以下内容-

{
    "properties": {
        "data": {
            "properties": {
                "Testresults": {
                    "items": {
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "address": {
                                "type": "string"
                            }

我从mydata模式中删除了Parse Json,仍然在输出中获得了相同的输入json。

我想从输入json中删除mydata元素并将其进一步传递,在parseJson中应该怎么做?

Parse Json

之后的预期输出
{
    "data": {
        "Testresults": [
            {
                "name": "",
                "address": "",

enter image description here

1 个答案:

答案 0 :(得分:1)

根据您的要求,我在下面发布了我的步骤供您参考。

在我的逻辑应用程序中,我使用以下json作为输入数据:

{
    "data": {
        "Testresults": [
            {
                "mydata": {
                    "id": "111",
                    "uri": "url",
                    "type": "demo1"
                },
                "name": "Michael",
                "address": "abc"
            },
            {
                "mydata": {
                    "id": "222",
                    "uri": "url",
                    "type": "demo2"
                },
                "name": "Daniel",
                "address": "def"
            }
        ]
    }
}       

首先,我创建一个变量来存储它。 enter image description here

然后,解析json。 enter image description here

在那之后,我们可以使用液体。我们需要先create an integration accountlink to the logic app,然后upload the liquid map如下所示:

{
    "data": {
        "Testresults": [
            {% for testresult in content.data.Testresults %}
            {
                "name": "{{testresult.name}}",
                "address": "{{testresult.address}}"
            },
            {% endfor %}
        ]
    }
}

现在,我们可以使用“将JSON转换为JSON”操作来进行转换。 enter image description here

运行逻辑应用程序,我得到了我们期望的结果。(没有“ mydata”) enter image description here

希望对您的要求有所帮助〜