I am building a flow that has a custom object with, let's say, the following data in json:
{
"foo": "a",
"bar": "b",
"baz": 100
}
This json comes from a Web API and may change depending on what is being sent. I wanted to know if there is a way to extract the list of properties to loop over. I.E, in this case I would have a list of Text ["foo", "bar", "baz"]
I tried the following in a condition and an object assigned to a variable
This:
variables('YourVariable')?['YourProperty'] is equal to null
was not evaluating to true, even when property didn't exist. But this:
empty(variables('YourVariable')?['YourProperty']) is equal to true
was working fine.
Thanks, @Henrik_M . I have something like that already in place, but I was curious if there was something less hacky. Ah well.
I'm not sure if there is a way to extract the property names from the object, put I guess you could use a regex "hack" to grab them from the JSON string. Try pasting this into your desktop flow:
SET JSON TO $'''{
\"foo\": \"a\",
\"bar\": \"b\",
\"baz\": 100
}'''
Text.ParseText.RegexParse Text: JSON TextToFind: $'''(?<=\").+?(?=\":)''' StartingPosition: 0 IgnoreCase: False Matches=> Matches
eetuRobo
64
Super User 2025 Season 1
Nived_Nambiar
18
Super User 2025 Season 1
CU12050101-0
12