Getting a Sting out of an Object - Logic Apps

So I ran into a rather annoying issue the other day. 

I had parsed some JSON in logic apps then and wanted to use the output in a condition statement. 

This is when the issue started for me. I tried the to String expression to turn the separate outputs into a string, however this didn't work. Not sure why I thought it would as that is never how it works but hey ho beginners mistake for sure.

I needed the string so that I could use it in a condition which kept breaking as I was passing an array into the condition rather than the string.

The work around I ended up using was to use the First() function to get the string from the array.

It worked like so:

I first used a Parse JSON on the object, as seen below





After you have Parsed your JSON you can choose whatever action you want to use but I will be using a compose action for this demonstration. After choosing an action instead of just choosing the "Useful Information" in dynamic content, I used an expression. The function I used for the expression was "First()" this enabled me to pull the string from the array. As seen below.

first(body('Parse_JSON')?['usefulInformation'])

Proof it works, 



Hope this helps, had me stumped for a while :)









Comments

Popular posts from this blog

Finding all Network Interfaces that are connected to Virtual Machines in Azure

AD PowerShell Script to see when a list of users last changed their passwords.

AD PowerShell script to add/remove a list of users from a group