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

Parse JSON output

I have JSON objects return from HTTP request. Sample object:

{

"meta": {

"somedata": "value"

}

"group": [

{

            "name": "myname",
            "url": "https://somesortofurl.com/914765"

},

{

            "name": "myname2",
            "url": "https://somesortofurl.com/9147644"

}

]

}

 

I want to create a 1) for each loop to extract only url from all the objects  2) and also the numeric values from the url so left(value,6). I will use the numeric value to create another http request. 

 

I tried For Each also tried to do it by compose using something like trigger()['group']['url'] but can't get this to work.  Any guidance would be much appreciated

 

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Parse JSON output

Hi @smerchant,

 

Have you tried the parse JSON action?

Parse JSON messages

 

Besides, you should be able to reference the trigger output through:

TriggerBody()?['group']?['url']

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper I
Helper I

Re: Parse JSON output

Thanks for a response @v-micsh-msft.  I indeed have used JSON Parse.  How should I add TriggerBody in the expression is it like TriggreBody('ParseOutput')?['server_list']?['url']?

 

 

Here are some screenshots

 

 

Output received from the JSON Parse

 Screenshot_8.png

 

Flow Screenshot

 

 

 flow.png

 

Error:

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('HTTP')' is of type 'String'. The result must be a valid array.

 

Highlighted
Helper I
Helper I

Re: Parse JSON output

@v-micsh-msft please could you help?  Thanks,

Highlighted
Frequent Visitor

Re: Parse JSON output

Try using 

Body('Parse_JSON')?['Group']?['URL']

Or

Body('Parse_JSON')?['Group']?['1']?['URL']

Or

Body('Parse_JSON')?['Group']?['1']?['URL']

The first option works for me, but I dont have duplicate entries under the header (i.e.: you have multiple entries for URL). So I guess you will have to refer to them by index. 

 

Do let us know what works. 

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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!

Top Kudoed Authors
Users online (7,687)