web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : NcWYl5Wp6dzQSneJqVLhkr
Power Automate - Building Flows
Answered

Convert Dynamic Key Name/Value or Dictionary to something useful like an array

Like (0) ShareShare
ReportReport
Posted on 30 Aug 2022 18:45:25 by 16

In Power Automate cloud, a Micorosoft connector I'm using returns tag data (name:value) like so:

 

"tags": {
      "randomTagName""randomValue",
      "anotherTagName""anotherRandomValue",
      "yetAnotherTagName""yetAnotherRandomValue"
    },

where the tag names can change (along with the value) and there can be any number of them but there is only the name & value. I don't care what they are, I just need to return this structure to Power Apps where I'll then use as a 2 column table identified as Name, Value supplying the data from Power Automate.

Since the data isn't returned as an array, what's the best way to parse the name/value pairs into a usable format?
  • TWeiss Profile Picture
    16 on 02 Sep 2022 at 17:15:58
    Re: Convert Dynamic Key Name/Value or Dictionary to something useful like an array

    Update - the above solution worked exactly as I needed, however once I implemented and tested it with a larger data set, I had to try another approach. I had an ApplyEach loop processing each record performing some other data transformations in addition to the one above, and the ApplyEach loop was just adding too much time to the whole process. 

    I still wanted the 'tags' to be a 2 column table that I could hook up easily to a Power Apps data table.  So in the Response action I modified the JSON schema to look like:

    "tags": {
                            "type""object",
                            "properties": {},
                            "additionalProperties": {
                                "type""string"
                            }
                        },

     

    and then hooking that to a data table resulted in the column headers to be assigned "key", and "value", which is fine.

    Capture7.JPG

     

  • TWeiss Profile Picture
    16 on 30 Aug 2022 at 20:22:45
    Re: Convert Dynamic Key Name/Value or Dictionary to something useful like an array

    Perfect. I had thought of doing a split somehow but didn't think about the 'replace' part. Works just as I needed and I can put the result in the HTTP Response as I've done with some other flows.

    I love that it's all done within a single Select.😀

     

    Will definitely check out your channel for more ideas.

     

    Thanks,

     

    Tim

  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on 30 Aug 2022 at 20:01:54
    Re: Convert Dynamic Key Name/Value or Dictionary to something useful like an array

    Hi @TWeiss 

     

    Are you looking for:

     

    DamoBird365_0-1661889489883.png

     

    You'll need to convert the object to a string.  Remove the { } " by using the replace() expression x3.  You can then split on , to create a new array and then split on : to create each value of the two keys Name and Value.  This is all done in a single select action.

     

    split(replace(replace(replace(string(outputs('ComposeTags')),'{',''),'}',''),'"',''),',')

    split(item(),':')?[0]

    split(item(),':')?[1]

     

    The flow would look like follows:

    DamoBird365_1-1661889619220.png

     

    Not that in order to return an array to a PowerApp, you need to either parse it with a little trick based on a string (as there are no native parsing actions) OR use the HTTP Response (Premium).


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete