Thanks for reaching out on Microsoft Q&A!
I've tested it in my test lab, and I think in your case I think it's best to use a 'Select' action. This type of action basically does a loop over an array, making it possible to select values from that array and refer them to new attributes in a newly defined JSON easily.
Please note that my screenshots are still in the "old" designer, where yours are in the "new" designer. Nevertheless, the expressions and snippets will work on your end as well.
So, first you'll need an array. Since your 'Get current weather' action is placed within a 'For each' loop, you can directly refer to the body of that action outside of the loop, turning it automatically into an array of all bodies within the loop. You can do this by adding the following expression in the 'From' field:
body('Get_current_weather')
Next, you want to assign new attributes, and use the values of the weather response body to form a new JSON trimmed the way you want it. When looking at the response of MSN Weather it's kinda "complex", in that sense: it contains a lot of objects within objects. Therefor you need to point to the actual value you need, using the expressions below:
- Location:
item()['responses']['source']['location']
- Condition:
item()['responses']['weather']['current']['cap']
- Temperature:
concat(item()['responses']['weather']['current']['temp'],item()['Units']['temperature'])
In my last code snippet, the one for temperature, I've used "concat" to paste two values together, being: temperature and unit of temperature, so it returns "22°C" instead of just the number "22". If you don't want this, and only want the number, you can simply use this code:
item()['responses']['weather']['current']['temp']
Lastly, you can set the body of your 'Response' action to contain the output of the 'Select' action, now making your flow look somewhat like below:
Hope this helps! Please click 'Accept answer' if it did. Feel free to drop addtional queries in the comments below :-)
Kind regards,
Sonny