Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 7BD4UQlSwqrFDvebZpmV77
Power Automate - General Discussion
Answered

How to select a Dynamic Json Property name

Like (0) ShareShare
ReportReport
Posted on 31 Jan 2023 21:51:00 by 5

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.

  • Verified answer
    Chriddle Profile Picture
    7,678 Super User 2025 Season 1 on 25 Mar 2024 at 08:28:55
    Re: How to select a Dynamic Json Property name

    Chriddle_0-1711355196242.png

    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"
     }
    ]
  • powerappsusercr Profile Picture
    2 on 22 Mar 2024 at 21:30:33
    Re: How to select a Dynamic Json Property name

    Hey Juan, im in the same situation. How did you accomplish that?

     

    Thanks

  • juanpowerapps91 Profile Picture
    5 on 01 Feb 2023 at 13:49:31
    Re: How to select a Dynamic Json Property name

    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

  • SudeepGhatakNZ Profile Picture
    14,303 Most Valuable Professional on 31 Jan 2023 at 23:45:42
    Re: How to select a Dynamic Json Property name

    @juanpowerapps91 ,

    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']

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading complete