cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
omh
Helper II
Helper II

Parse JSON string in Power APPS

Hello,

 

Is there a way to parse a JSON string directly in PowerApps, and not in Flow? I have succeeded in parsing it in Flow, but I need to parse it in PowerApps directly.

 

Thank you.

Oana

15 REPLIES 15

Hello @jainnishant 

 

From what I can gather from you question. Here is the code I would use :

ClearCollect(
    MyData,
    MatchAll(
        JsonString,
        "\{""Capacity"":(?<Capacity>\d*),""ClientContactName"":""(?<ClientContactName>[^""]*)"",""Site_Details"":""(?<Site_Details>[^""]*)"",""Type"":""(?<Type>[^""]*)"",""projectItemType"":""(?<projectItemType>[^""]*)"",""strategy"":""(?<strategy>[^""]*)""\}"
    )
);

 

Important note that is not in my first comment : the example show a JSON with only strings. If you don't have any knowledge about regex and matching I would recommend heavily to read documentation on the subject.  Here is the documentation about MatchAll . 

 

But for integer value you can use (?<MyInteger>\d*) instead of ""(?<MyString>[^""]*)"". Or for any number, simply remove the two "".

Be aware that the value in the collection of Power Apps will be as a string. Use Value() to fix that.

Hi @vladimir84, could you please provide your setup for the response part in your solution? I tried your flow, but end up with a collection with only the value "true" and not the information from my JSON. So I am doing something wrong when setting up my flow. 
This is how my flow looks at the moment:

mirfro_0-1605616343369.png

 


Thank you for your help!

Hi @mirfro 

Here is mine, and unfortunately it takes a bit of tweaking. I had the same issue:

vladimir84_0-1605616807447.png

If I remember correctly, in Parse JSON you can have the type ["string", "null"], but you can't have it in the Response.

 

To get the correct JSON structure, I'd do a Set(varJSONtable, JSON(collectionName)) and then assign to the Label the varJSONtable. Double-click into the label to select all and copy-paste the JSON into Flow.

 

Hope it helps.

 

Thanks @vladimir84, seeing your solution and your mention that the Response cannot have the type ["string", "null"] made it function! Had to do a bit of tweaking and update the flow reference in PowerApps, but it worked in the end!

Thanks for your imperfect solution. It works PERFECTLY for me! Gotto love this community!

TedBabcock
Helper II
Helper II

Mr Dang has addressed this issue. He provides a clear explanation and, even better, an app that will create the complicated formula you need to parse JSON in PowerApps:

https://powerapps.microsoft.com/en-us/blog/return-an-array-from-a-sql-stored-procedure-to-powerapps-...

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (756)