cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zeedee11
Frequent Visitor

Changing array format to remove curly brackets

Hello. I want to change an array like this:

 

[
  {
    "616975780": "red"
  },
  {
    "616978104": "orange"
  },
  {
    "617008215": "green"
  },
  {
    "617010339": "blue"
  },
  {
    "617015079": "yellow"
  },
  {
    "617012891": "brown"
  },
  {
    "617016668": "purple"
  },
  {
    "617028524": "pink"
  },
  {
    "617031083": "magenta"
  }
]

 

 

Into this:

 

[
  {
    "616975780": "red",
    "616978104": "orange",
    "617008215": "green",
    "617010339": "blue",
    "617015079": "yellow",
    "617012891": "brown",
    "617016668": "purple",
    "617028524": "pink",
    "617031083": "magenta"
  }
]

 

 

I tried doing an apply to each and appending a new array with the key:values but I ended up with the same thing.

 

Any help is appreciated. Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yiwenxie-msft
Microsoft
Microsoft

Hi @zeedee11 

 

You can try the flow below:

3.3-13.PNG

 

The detailed step for ‘Compose’:

3.3-14.PNG

 

The expressions used:

 

‘Compose 2’:

string(outputs('Compose'))

 

‘Compose 3’:

replace(outputs('Compose_2'),'},{',',')

 

‘Compose 4’:

json(outputs('Compose_3'))

 

For more info about the functions string(), outputs(), replace(), json():

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

 

The result of the flow is:

3.3-15.PNG

 

If you still have the problem, please feel free to let me know.

 

Best Regards,
Community Support Team _ Kira Xie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiwenxie-msft
Microsoft
Microsoft

Hi @zeedee11 

 

You can try the flow below:

3.3-13.PNG

 

The detailed step for ‘Compose’:

3.3-14.PNG

 

The expressions used:

 

‘Compose 2’:

string(outputs('Compose'))

 

‘Compose 3’:

replace(outputs('Compose_2'),'},{',',')

 

‘Compose 4’:

json(outputs('Compose_3'))

 

For more info about the functions string(), outputs(), replace(), json():

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

 

The result of the flow is:

3.3-15.PNG

 

If you still have the problem, please feel free to let me know.

 

Best Regards,
Community Support Team _ Kira Xie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks that worked! I condensed mine a little bit since I already had the array in a variable

zeedee11_0-1614787745146.png

 

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (11,897)