cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

show a value from a JSON

Hello, Is it possible to fetch a particular tag and a value from a json text. Below is my gallery screen.

P_SA_0-1603200830747.png


I need to show the Expense category in the gallery and remove the unwanted text from the json. How can i achieve this. ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@P_SA 

Let's change your expense category label then to the following (just to cut out the middle-man/label)

Match(
    LookUp(TmpWFDocDetails,RecordID=ThisItem.RecordID, HeaderData), 
    """Expense category"": *""(?<value>[^""]+)"
).value

Note: I also added a * in the pattern as I noticed you did not have spaces after your elements.  This will match zero or more spaces.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

9 REPLIES 9
Highlighted
Resolver I
Resolver I

According to my perspective, as this is a text there isn't direct way to do it. I'll suggest you to convert it into JSON value first. "JSON" function has been newly released by the MS. Please find the link attached.

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-json

 

You can go something like:

JSON(TextboxName.Text, JSONFormat.IndentFour) //Textbox is the part of the gallery

 

Then you can play with this json object to get the attribute you want or use flow to parse it.

 

Thanks for having my input. If you like it , a thumbs up is highly appreciated!

 

Warmly 🙂

 

Highlighted

it is in json format. below is how my data looks. 

 

P_SA_0-1603203123006.png

 

Highlighted
Super User III
Super User III

@P_SA 

There is no direct conversion from JSON text in PowerApps.

However, for this you can use a regular expression:

Match(yourJSON, """Expense category"": ""(?<value>[^""]+)").value

This will show the value of your Expense category in your JSON.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

I get a blank value

P_SA_0-1603204144321.png

 

Highlighted

@P_SA 

What is going on in Label9_1.Text?  Is that your original JSON?  What is the formula on that control?

This pattern match works 100% for getting a String value of a named JSON element - which yours is.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

this is what I have in the label9_1.text.

First(Filter(TmpWFDocDetails,RecordID=ThisItem.RecordID)).HeaderData

P_SA_0-1603204859706.png

 

Highlighted

@P_SA 

Let's change your expense category label then to the following (just to cut out the middle-man/label)

Match(
    LookUp(TmpWFDocDetails,RecordID=ThisItem.RecordID, HeaderData), 
    """Expense category"": *""(?<value>[^""]+)"
).value

Note: I also added a * in the pattern as I noticed you did not have spaces after your elements.  This will match zero or more spaces.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Highlighted

Great it worked like a charm. thanks a bunch for your help.

Highlighted

@P_SA 

Excellent!  I'm glad we finally got you to a solution! It's always nice to have details on how to do these things.
If this resolved your problem, please go back and find which message solved the problem and mark it as a solution so that other having the same issue can find a solution quickly.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,924)