Neo
Neo

Reputation: 16219

how to remove json element using json parse in logic app?

Input json -

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

in side Parse Json schema added as below -

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

I have removed mydata from Parse Json schema still in the output getting same input json.

I want to remove mydata element from input json and pass it further , what should be done for that in parseJson?

expected output after Parse Json

{
    "data": {
        "Testresults": [
            {
                "name": "",
                "address": "",

enter image description here

Upvotes: 0

Views: 2012

Answers (1)

Hury Shen
Hury Shen

Reputation: 15734

For your requirement, I post my steps below for your reference.

In my logic app, I use the json below as the input data:

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

First I create a variable to store it. enter image description here

Then, parse json. enter image description here

After that, we can use liquid. We need to create an integration account and link to the logic app, then upload the liquid map shown as below:

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

Now, we can use "Transform JSON to JSON" action to do convert it. enter image description here

Run the logic app, I get the result we expect.(without "mydata") enter image description here

Hope it would be helpful to your requirement~

Upvotes: 1

Related Questions