cancel
Showing results for 
Search instead for 
Did you mean: 

Parse JSON in PowerApps

Hi everyone,

 

The new JSON function in PowerApps is great and we have been using it extensively. Another great addition would be to parse JSON directly in PowerApps. If PowerApps receives a stringified JSON string, it should be able to easily Parse this and use this data in the app, to write it into a collection, variable or whatever.

 

We have been using the HTTP response in flow to return dynamic data to PowerApps, but seeing that this is now longer included in the Office 365 entitlement and that normal Respond To PowerApps Flow action not supporting Arrays or JSON, this request is quite urgent.

 

Please let us know if you have any questions or suggestions.

 

Kind regards

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1

Status: Under Review
Comments
Advocate I

Please do this, it's extremely important! We are losing so much functionality here.

Helper I

This would be very useful. 

 

Right now I have a SharePoint data source in which I need to store an array. Since SharePoint lists can't take an array, they recommend to use a JSON string. Putting it into JSON is just fine to send over but when I want to retrieve data back and use it as an array, there's no way to parse it. 

Update: If anyone encounters this same issue I've found luck in putting my items in the SharePoint list using 

 

Left(Concat(Table, Result & ","), Len(Concat(Table, Result & ",")) -1)

 


and then retrieving them using

 

Split(Table, ",")

 

 

This isn't as versatile as JSON but it works for my simple array. 

Regular Visitor

I doubt that MS will ever give this so simple JSON parse functionality, if given then no one will use "premium" http response action in Power Apps flows!!

Resolver I

Using response from HTTP connector should work returning back to PowerApps. This is how response form a SQL Server query are returned. PowerApps understand that as a table/collection.

Regular Visitor

We have an action with Output parameter string "Output", in this parameter we are returning an array in json. We need to be able in power apps to parse this json to provide it to a collection.

 

How should we do it if it's not possible to convert the json array in a data source for the collection?

Continued Contributor

@Oztrea if you mean Action from Power Automate, you have a Parse JSON action right there. 

To return the composed array in a manner that PowerApps can Collect() it, you need to craft a http Response:

response.png

 

The schema is necessary to define the data structure that will be Collect()able. 
The "Generate from sample" is very useful to generate the initial schema without a laborious manual crafting. 
In many cases that will suffice, but the schema may require tweaking, if your data sample has blank fields, you will have to set their data type manually. 

Regular Visitor

@TiagoFreire: the action you suggested requires premium connection. Its no longer a free one.

Continued Contributor

Yes, it is a premium connector. It works very well if you have access to it. 

It is unfortunate that Microsoft paywalled it. 

 

If all you have access to is powerApps default text response, the best you can do is to combine functions Split() and ForAll() to collect it, like a makeshift, rudimentary csv parser. Depending on the the content, you might need custom separators and it could be brittle code. Better help would be provided on a separate thread, this one is reinforce the suggestion for a Parse JSON() function inside PowerApps .

Regular Visitor

@TiagoFreire: thats the worse part actually: since PowerApps flows runs with individual user context, need to get that many user licenses for using premium connector in PowerApps triggered flow. Now imagine, if PowerApps has 40,000 users, need to pay MS premium license cost for 40,000 users 😞

Regular Visitor

@TiagoFreire , no we are calling an action in Dynamics 365, in one of the Output parameter (string) we have a stringified json and we would like to transform the array in this parameter in a collection as the source of the gallery.

 

{

"Output": "{\"array\": [{sourceobj1},{sourceob2}]}"

}

 

in PowerApps we have json() = JSON.stringify (in javascript)

what is in PowerApps JSON.parse (in javascript)

 

But I think we will continue to develop custom webresource until there's an easy way to do in powerapps...