How do I convert a string to an array:
"[\"123.123.123.123\",\"123.123.123.123\"]"
Let's say you have a string like above, how do I convert it to an array via expressions or a module. It comes from a request like below.
{
"headers": {
"ip": "[\"123.123.123.123\",\"123.123.123.123"]"
}
}
First, you need to extract the value of your IP address string from the headers of your HTTP call/trigger.
I can't help you with the exact answer because I don't know the name of the action that's giving you that result but, using the same approach to Initialise
a variable, you can get the string.
So something like ...
outputs('HTTP')['headers']['ip']
Then, use the json
function over the top of that value ...
The expression in the second step is ...
json(variables('Array As Text'))
Naturally, it can all be performed in one step though, like thus ...
json(outputs('HTTP')['headers']['ip'])
Given what you've provided, translating that to your flow is something you'll need to take care of.
Result