Hello all,
I have a json output that looks similar to the below:
[
{
"39c04006-00d0-11e8-9bea-0275d4b83f51": {
"user_name": "test2"
},
"3a24d728-00d0-11e8-8494-0275d4b83f51": {
"user_name": "test3"
}
}
]
the name of the property aka the GUID above can be dynamic and this object array can have 3 or more objects. How can I turn this into a proper array so I can select all "user_name" from the json object.
From:
xpath(
xml(
json(
concat(
'{"Root":{"Item":',
outputs('Compose'),
'}}'
)
)
),
'/Root/Item/*'
)
Map Id:
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
xpath(
item(),
'name(/*)'
),
'_x0030_','0'),'_x0031_','1'),'_x0032_','2'),'_x0033_','3'),'_x0034_','4'),'_x0035_','5'),'_x0036_','6'),'_x0037_','7'),'_x0038_','8'),'_x0039_','9'
)
Map UserName:
xpath(
item(),
'string(/*/*)'
)
Result:
[
{
"Id": "39c04006-00d0-11e8-9bea-0275d4b83f51",
"UserName": "test2"
},
{
"Id": "3a24d728-00d0-11e8-8494-0275d4b83f51",
"UserName": "test3"
}
]
Hey Juan, im in the same situation. How did you accomplish that?
Thanks
Thank you for the answer. Unfortunately that's not going to work as the object is not an array. All the answers seem to indicate that this is not possible using out of the box functions in power automate. To loop through json objects you will need to use a c# or java script to accomplish this
You could retrieve the values using indexes instead of field names.
outputs('Compose')[0]['user_name']
outputs('Compose')[1]['user_name']
outputs('Compose')[2]['user_name']
rpersad
16
David_MA
10
Super User 2025 Season 1
Michael E. Gernaey
8
Super User 2025 Season 1