web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Parse arbitrary number...
Power Automate
Answered

Parse arbitrary number of JSON fields into table

(0) ShareShare
ReportReport
Posted on by 29

hello,

 

I have the following JSON (coming from an online form):

 

 

{
 "headers": {
 "Connection": "Keep-Alive",
 "Expect": "100-continue",
 "Host": "prod-11.australiasoutheast.logic.azure.com",
 "User-Agent": "CognitoForms",
 "X-Requested-With": "XMLHttpRequest",
 "Content-Length": "1078",
 "Content-Type": "application/json"
 },
 "body": {
 "Form": {
 "Id": "1",
 "InternalName": "Testing",
 "Name": "Testing"
 },
 "$version": 8,
 "$etag": "W/\"datetime'2022-11-14T11%3A01%3A04.8220238Z'\"",
 "Name": "kav test",
 "Email": "kav@somewhere.com",
 "License": "Mailbox",
 "Office": "Sydney",
 "Entry": {
 "DateCreated": "2022-11-14T11:01:04.508Z",
 "DateSubmitted": "2022-11-14T11:01:04.508Z",
 "DateUpdated": "2022-11-14T11:01:04.508Z",
 },
 "Id": "1-1"
 }
}

 

 

 

What I would like to do is convert the data into a table. However, the number of fields may change from request to request and I want to be able to handle that dynamically. The logic is fairly simply, use all fields under 'body', except for; Form, $version, $etag, Entry and ID (so in this case create a table from fields; Name, Email, License, Office).

 

Tried doing this with a loop and conditional statement but didnt get very far...

Categories:
  • Sundeep_Malik Profile Picture
    6,501 on at

    Hey @Kav7 

     

    I saved your above data in a compose and did the following, you can copy the steps:

     

    Sundeep_Malik_5-1668432832315.png

     

    In Compose saved your data:

    Sundeep_Malik_1-1668432342202.png

    Then used another compose and saved just the body part of your json data:

    Expression used: outpus('Compose').body

    Sundeep_Malik_2-1668432375435.png

    Next I used parse json, passed the output of compose 2 in it and in generate for sample pasted the output of compose 2. Giving below the data what you have to pass in the schema:

    {

        "type": "object",
        "properties": {
            "Form": {
                "type": "object",
                "properties": {
                    "Id": {
                        "type": "string"
                    },
                    "InternalName": {
                        "type": "string"
                    },
                    "Name": {
                        "type": "string"
                    }
                }
            },
            "$version": {
                "type": "integer"
            },
            "$etag": {
                "type": "string"
            },
            "Name": {
                "type": "string"
            },
            "Email": {
                "type": "string"
            },
            "License": {
                "type": "string"
            },
            "Office": {
                "type": "string"
            },
            "Entry": {
                "type": "object",
                "properties": {
                    "DateCreated": {
                        "type": "string"
                    },
                    "DateSubmitted": {
                        "type": "string"
                    },
                    "DateUpdated": {
                        "type": "string"
                    }
                }
            },
            "Id": {
                "type": "string"
            }
        }
    }

    Sundeep_Malik_3-1668432446118.png

     

    After that you can use the dynamic fields as you like:

    Use them all together by doing this:

    Sundeep_Malik_6-1668432903023.png

     

    Or use them separately by using them in separate composes:[I have added them in a single compose, but in your case you can add them directly in separate composes or wherever you want.]

    Sundeep_Malik_7-1668432915720.png

     

    Final Output:

    Compose 3:

    Sundeep_Malik_8-1668433015872.png

     

    Compose 4:

    Sundeep_Malik_9-1668433036836.png

     

     

    If this was what you were looking for you can accept this answer as a solution. And if you liked the explanation, you can give a thumbs up. It really helps. Thanks.   🙂

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    I would use removeProperty to remove the unwanted properties.

     

    Full flow below. I'll go into each of the actions.

    grantjenkins_0-1668436343839.png

     

    The first variable just contains all your JSON.

    grantjenkins_1-1668436480531.png

     

     

    The second variable converts that to JSON and gets just the body element. The second variable is called data. It uses the following expression:

    json(variables('json'))?['body']

    grantjenkins_2-1668436548041.png

     

    Compose Props contains an array of properties I want to remove from the body element.

    grantjenkins_3-1668436606873.png

     

    Next, we iterate over each of the properties using an Apply to each. And for each property we use removeProperty to remove the property, then replace the value of data with the new JSON. The expression I use is:

    removeProperty(json(variables('data')), items('Apply_to_each'))

    grantjenkins_4-1668436769251.png

     

    Then, after the loop, I convert the data to JSON. The expression is below.

    json(variables('data'))

    grantjenkins_5-1668436944956.png

     

    And lastly, to add it to our Create HTML table I wrap the output into an array [ ] as so.

    grantjenkins_6-1668437011423.png

     

    The final output in this instance would be:

    grantjenkins_7-1668437071309.png

     

    Hopefully, that's what you're after.

  • Kav7 Profile Picture
    29 on at

    Thanks to you both, the solution from @grantjenkins is what I was after, as it allows for any arbitrary number of attributes in the source JSON, have got it working, amazing thank you! 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 298 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard