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 Apps / Collect JSON string in...
Power Apps
Answered

Collect JSON string into columns

(0) ShareShare
ReportReport
Posted on by

Good evening,

 

I have this JSON string returned from Microsoft Automate and I'd like to turn the results into columns. The sample return string looks like this:

 

 

{"__metadata":{"id":"123","uri":"api/Items(1)","etag":"\"1\"","type":"SP.Data.SP.Items"},"Title":"TitleVal","Column1":"Column1Val","SomeOtherCol":"SomeOtherColVal","UserID":"1697"}

 

 

I know I only want the string just after the first "}" and so I generate this code:

 

 

Last(FirstN(Split(sampleString.Text, "}"), 2)).Result

 

 

From here, what is the best method to converting the result from this:
sample_start.png

into a collection with this:

TitleColumn1SomeOtherColUserID
TitleValColumn1ValSomeOtherColVal1697

 

The logic that I think may work is to to not even do a split yet and conduct a find for each field and then split after to find the values for it. I'm just bouncing ideas here and see if I'm working in the right direction.

EDIT: I got this and it's giving me the correct results but I'm kinda hardcoding the number of spaces to retrieve. There's got to be a better / dynamic way.

 

Substitute(First(Split(Mid(sampleString.Text, Find("SomeOtherCol", sampleString.Text) + 13 +1), ",")).Result, Char(34), Blank())


EDIT #2: I think I am going to settle with this logic:

Substitute(Last(Split(First(Split(Mid(sampleString.Text,Find("Title",sampleString.Text)),",")).Result,":")).Result, Char(34), Blank())

 

Categories:
I have the same question (0)
  • royg Profile Picture
    on at

    If you have control over the Power Automate Flow that your app is using, you could return the JSON object instead of the result string so your app can consume the result as a collection/object without parsing it. Try adding a Response action (Premium) and place your JSON text into the Schema builder. 

  • CU24061526-1 Profile Picture
    on at

    hehe, unfortunately I am not allowed to consume any premium connectors, but taking a bit of your idea, I might sanitize the data before consuming it inside PowerApps. 

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @MrNguyen ,

    Have you solved your problem?

     

    Based on the needs that you mentioned, actually, you could consider convert the JSON String into the JSON Table, then pass the JSON Table back to your canvas app.

     

    I have made a test on my side, please consider take a try with the following workaround:

    Flow's configuration as below:

    1.JPG

    Add a "Response" action at the bottom of your flow, set the Body field to following:

    json(variables('JSONString'))

    Note: Use the json expression to convert the JSON String into JSON Table

     

    Set the "Response Body JSON Schema" field to following:

    {
     "type": "object",
     "properties": {
     "__metadata": {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "uri": {
     "type": "string"
     },
     "etag": {
     "type": "string"
     },
     "type": {
     "type": "string"
     }
     }
     },
     "Title": {
     "type": "string"
     },
     "Column1": {
     "type": "string"
     },
     "SomeOtherCol": {
     "type": "string"
     },
     "UserID": {
     "type": "string"
     }
     }
    }

     

    App's configuration as below:

    2.JPG

    Set the OnSelect property of the "Retrieve Collection" button to following:

    ClearCollect(TableResult, 'PowerApp->Initializevariable,Response'.Run())

    The TableResult collection would look like below:

    3.JPG

     

    Please check and see if the following blog would help in your scenario (Pass table from flow to canvas app):

    https://powerapps.microsoft.com/en-us/blog/return-an-array-from-flow-to-powerapps-response-method/

     

    Please take a try with above solution, then check if the issue is solved. If the solution above is helpful in your scenario, or you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

     

    Best regards,

  • CU24061526-1 Profile Picture
    on at

    @v-xida-msft ,

    Thanks very much for this! I have yet to test this out since it uses a premium connector but I will save it and attempt it later if company allows me hehehe.

  • DH-27020923-0 Profile Picture
    on at

    Hey! Are there any non-premium work-arounds for this? Alternatively, importing  csv or excel file in stead of a json could work for me as well.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard