Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

How to turn array of objects into a single object in Power Automate

Posted on June 8, 2022June 12, 2022 by Tom

“I’ve got an array where each property is a separate object, how can I turn it into a single object using Power Automate flow?”


If you stay only in the Microsoft 365 environment, you probably won’t encounter this problem. Every array is either a simple array or an array with objects. But once you start processing data from other systems it might not be as clear. Instead of a single object you might receive an array of objects with each object representing one property. A format that can make your life quite complicated.

How do you turn it into a single object that’s easy to work with?

Power Automate array into object

Convert the array into a string

I believe that the easiest way is to “brute force” the conversion.

To turn it into a single object you must remove the },{ between the objects and replace them with a comma. But to use the replace(…) expression you’ll need a string, not an array.

string(outputs('Compose'))

Replace the },{ characters

Once you have a string, you can replace some parts of it. In this situation you should replace the },{ with a single comma.

replace(string(outputs('Compose')),'},{',',')

Turn it back into an array

The string now resembles the object, but it’s still a string. You can’t select a value from a string, nor can you navigate in an array-like looking string. You must turn it back into an array with an object using the json(…) expression.

json(replace(string(outputs('Compose')),'},{',','))

Remove the array

The last step is to remove the [ ] brackets representing an array as you don’t need it anymore since it’s a single object. Use the first(…) expression to take only the first (and only) object.

first(json(replace(string(outputs('Compose')),'},{',',')))
Power Automate array into object

And that’s it, you just turned an array of objects into a single object in your Power Automate flow.

Summary

You don’t need a fancy solution for everything when using Power Automate. Sometimes it’s fine to just adjust the data and force it into the desired format. All you have to do is follow your thought process – how would you do that step by step? Turn it into a combination of expressions and move on.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme