cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mmattar
Level 8

JSON Object get values

Hello all,
 
How can i traverse through this json object to grab the values i need which are all of them. I have the first one with:
first(body('Parse_JSON')?['ResultSets']?['Table1'])['item1'] in a compose action, how can i keep nesting through to get the others?
 
Thanks
 
{
            "OutputParameters": {},
            "ResultSets": {
                    "Table1": [
                         {
                                 "item1": 253
                         },
                         {
                                  "item2": 985
                         },
                         {
                                    "item3": 3159
                          },
                          {
                                     "item4": 3712
                          }
                   ]
             }
   }
1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: JSON Object get values

Hi @mmattar 

 

Since you are returning the response as a string, then you might want to perform manipulations in a way that it extracts the value out of it.
 
Expressions:
 
1st Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),2)).Result,"}","")
2nd Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),3)).Result,"}","")
3rd Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),4)).Result,"}","")
4th Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),5)).Result,"}","")
 
This will work in a way, you need to update the highlighted part with the index you want to get + 1. 
 
Else, you could use the Response action (a premimum connector and starightaway pass the json and parse it in PowerApps then)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

10 REPLIES 10
Dual Super User
Dual Super User

Re: JSON Object get values

Hi @mmattar 

 

You can directly use the parse json action to do this: 

s11.PNG

 

s12.PNG

 

s13.PNG

I stored the json in an array object for the source to the parse json action. You can directly bass the body/ output of previous action here. Click on generate schema and enter the sample payload and it will generate a schema for you. Based on that you will be able to access teh keys as dynamic content then. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

mmattar
Level 8

Re: JSON Object get values

hey thanks for the reply, i implemented what you did but im still not seeing the items as dynamic content to choose from

Dual Super User
Dual Super User

Re: JSON Object get values

Hey @mmattar 

 

Can you share a screenshot of the flow? Can you confirm the schema has been entered correctly and generated in the JSON action. Also, what is the consecutive action that you have in the flow? If you could share a screenshot it would be easier to identify the issue and assist you with this. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

mmattar
Level 8

Re: JSON Object get values

pp.PNGpp1.PNGpp2.PNG

Dual Super User
Dual Super User

Re: JSON Object get values

Hey @mmattar 

 

Note that you can only pass strings in the Respond to PowerApps or Flow action and the schema that you generated has array and objects of integers (strings). And to choose even one value, it would put the action in apply to each and you cannot do that for the respond action. 

 

Based on the data you want to pass, you can add a compose action or a variable to store the data and then pass it to the respond action:

 

ee3.PNG

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

mmattar
Level 8

Re: JSON Object get values

pp3.PNGok so this is what i am getting back to powerapps, i tried creating a variable for each item, but it seems as if the apply to each control puts all the items in each variable, how can we seperate each item in its own variable

Dual Super User
Dual Super User

Re: JSON Object get values

Hi @mmattar 

 

Since you are returning the response as a string, then you might want to perform manipulations in a way that it extracts the value out of it.
 
Expressions:
 
1st Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),2)).Result,"}","")
2nd Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),3)).Result,"}","")
3rd Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),4)).Result,"}","")
4th Item: Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),5)).Result,"}","")
 
This will work in a way, you need to update the highlighted part with the index you want to get + 1. 
 
Else, you could use the Response action (a premimum connector and starightaway pass the json and parse it in PowerApps then)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

mmattar
Level 8

Re: JSON Object get values

Thanks for all this help, just one more question.

 

Substitute(Last(FirstN(Split(var1.test,"{"&Char(34)&"Lunch"&Char(34)&":"),2)).Result,"}","") 

 

In the area i have highlighted red, this is where i put my variable that holds the string of the values i got from the json. but i keep getting that this expression is invalid, here is my expression

 

Substitute(Last(FirstN(Split(variables('leaks'),"{"&Char(34)&"Lunch"&Char(34)&":"),2)).Result,"}","") 
Dual Super User
Dual Super User

Re: JSON Object get values

Hey @mmattar 

 

Can you share how you are creating this variable in PowerApps (the expression i shared is for powerapps). Also, variable('leaks') format is used on expressions for Flow. Here, in powerapps, you directly need to pass the variable name: 

 

Substitute(Last(FirstN(Split(leaks.stirngname,"{"&Char(34)&"Lunch"&Char(34)&":"),2)).Result,"}","") 
 
leaks is a variable created in powerapps to store the response returned by flow, stringname is the name of the variable from Flow. 
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
mmattar
Level 8

Re: JSON Object get values

just a misunderstanding on my end, thanks it works ! 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,727)