cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sim2KUK
Frequent Visitor

ParseJSON within PowerApps - Here is how

ParseJSON is brand spanking new. Started looking at it last week and it seems to be working nicely. Had a few issues on how to get data out myself in a Gallery, into a label. Finally sorted it so I thought I'd share.

 

Here is an example of how I’m using it so far …

 

‘ThisItem.Answer’ …. In a gallery contains the following …

 

[

  "Text 1",

  "Text 2",

  "Text 3"

]

 

… using the following code ….

 

Concat(Table( ParseJSON( ThisItem.Answer )), Text(Value) & "

")

 

… gives me …

 

                Text 1

                Text 2

                Text 3

 

 

Also … If you’re dealing with JSON holding records and fields like below. In this example, the gallery records now holds the data below in ‘ThisItem.Answer’ ...

 

[

  {

    "name": "TheFileName.xlsx",

    "link": "https://YourSite.sharepoint.com/sites/SiteName/_layouts/15/Doc.aspx?sourcedoc=%7B5747E771-9325-475A-..."

  }

]

… you can use the following to get a field into a label ..

 

With( First(Table( ParseJSON( ThisItem.Answer ))),

    Value.name

)

 

.. which will give you … ‘TheFileName.xlsx’.

 

As you are working with tables and records, maybe a ForAll could be used as well. Not yet tried this, if you do, past your results in this thread.

 

🙂

1 REPLY 1
RandyHayes
Super User
Super User

@Sim2KUK 

Yes...it is a long overdue function!!

 

It would be nice to provide a schema to it (in the case of records and tables), but it is easy to convert from the untyped result to either one.

 

Since ForAll is a table producing function, it is perfectly fit for returning a table of the parsed JSON.

The docs for the ParseJSON function have a so-so example of converting a JSON table to a typed table in PowerApps.

 

Thanks for sharing!

 

Oh...and if you haven't looked at Named Functions yet - well worth a look!!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,070)