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

How to parse json in a condition?

I'm tyrying to parse some json returned from a HTTP request. 

The request works fine, but I'm having trouble getting the variable I want test extracted correctly. 

The json returned is:

 

{ "Time":"12 Jul 2016 930 AM EST " ,"Direction":"225" ,"Gusts":"2.4" ,"Wind":"1.7" ,"Tempature":"78.9" ,"KPTime":"2016-07-12 14:24" ,"KPCard":"SSW" ,"KPDirection":"202" ,"KPGusts":"7.00" ,"KPWind":"6.61" }

 

I want to parse out out the value after this "Gusts":"2.4" to be value 2.4 and run a condition on it:

I assumed I could take the body as  'Gusts' : 'ERGust' and a condition of:

 

@greater(body('Http')['ERGust'], 5)

 

snip_20160712105444.png

 

 

 

 

The Flow is at:https://flow.microsoft.com/manage/flows/0f4174dc-4ffe-4e51-90af-f0ecbcf25981

 

Any thoughts?

 

Thanks

Andrew

 

5 REPLIES 5
Highlighted
New Member

Re: How to parse json in a condition?

Did you find a way to get this to work? Same situation

Highlighted
Power Automate
Power Automate

Re: How to parse json in a condition?

The above example is very close but not quite correct. If you have 

{ "Time":"12 Jul 2016 930 AM EST " ,"Direction":"225" ,"Gusts":"2.4" ,"Wind":"1.7" ,"Tempature":"78.9" ,"KPTime":"2016-07-12 14:24" ,"KPCard":"SSW" ,"KPDirection":"202" ,"KPGusts":"7.00" ,"KPWind":"6.61" }

 

Then all you need to do in the condition is:

 

@greater(int(body('Http')['Gusts']), 5)

 

And then it'll work. I think the issues with the original post are:

1. You don't need to re-map anything in the HTTP call - just use the output-as is. The Body for that card should be the body you're passing to the backing API in the POST call -- so you should probably leave that blank (or provide whatever JSON that backing API requires in the POST).

2. The API is returning Gusts as a string, but you want to compare it as an integer. That means you have to use the int() function.

 

I hope this helps!

Highlighted
Frequent Visitor

Re: How to parse json in a condition?

How do you parse json to get the string from a HTTP POST.

 

I am working with the following response body:

 

Status Code: 200
Body: {"jsonrpc":"2.0","result":{"random":{"data":["48588608"],"completionTime":"2016-12-16 03:28:36Z"},"bitsUsed":27,"bitsLeft":249460,"requestsLeft":980,"advisoryDelay":230},"id":32400}

 

I want to extract the value 48588608 from result/random/data.

 

I am using Mcrosoft Flow and want to uise this string in an email, for example.

 

 

 

 

Highlighted
Microsoft
Microsoft

Re: How to parse json in a condition?

I'm now getting an error message:

'The template language expression 'greater(int(body('http')['Gusts']), 5)' cannot be evaluated because property 'Gusts' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.

Any thoughts how to debug this.  I'm really returning a Json string, not a well-formed http string.

The return string from the URL is:

{"Time":"December 16, 2016 10:00 am EST" ,"Card":"W" ,"Direction":"260" ,"Gusts":" 17.5" ,"Wind":" 13.6" ,"Tempature":" 20.7" ,"KPTime":"2016-12-16 15:12" ,"KPCard":"NW" ,"KPDirection":"325" ,"KPGusts":"17.88" ,"KPWind":"13.41" }

 

thanks

Andrew

Highlighted
Microsoft
Microsoft

Re: How to parse json in a condition?

I got the following to work for my Json:

 

@greater(float(json(body('http'))['Gusts']), 30)

 

in the condition and

 

Wind is @{json(body('http'))['Gusts']} from the @{json(body('http'))['Direction']} degrees from north

 

for the notification box.

 

Hope this helps

 

Andrew

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,607)