cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
P_SA
Helper V
Helper V

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

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

View solution in original post

9 REPLIES 9
RishabBehl31
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 🙂

 

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

 

P_SA_0-1603203123006.png

 

RandyHayes
Super User
Super User

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

I get a blank value

P_SA_0-1603204144321.png

 

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

this is what I have in the label9_1.text.

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

P_SA_0-1603204859706.png

 

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

View solution in original post

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

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,120)