cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sharepointguy
Advocate I
Advocate I

Array to Object

Hi All,

 

I have the below array which I want to convert in an Object.

 

{

"values": [

  [

   "Header1",

   "Header2"

  ],

  [

   "Value1",

   "Value2"

  ],

  [

   "Value11",

   "Value22"

  ]

 ]

}

 

My desired output is

 

{

  [

     "Header1":"Value1",

     "Header2":"Value2",

  ],

  [

     "Header1":"Value11",

     "Header2":"Value22",

  ]

}

 

Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Microsoft
Microsoft

Hi @sharepointguy 

 

That's a very peculiar looking array of arrays!  An array of objects would be easier, saying that, this is possible with a select.

 

From: range(1,add(length(outputs('Compose')?['values']),-1))

which is basically skip integer 0 (the header) and run til length of values array minus 1

 

keys are:

outputs('Compose')?['values']?[0]?[0]
outputs('Compose')?['values']?[0]?[1]
values are:
outputs('Compose')?['values']?[item()]?[0]
outputs('Compose')?['values']?[item()]?[1]
 
I stuck your array into a compose
DamoBird365_1-1629318575876.png

 

and converted it as requested....

 
DamoBird365_0-1629318553158.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

View solution in original post

2 REPLIES 2
DamoBird365
Microsoft
Microsoft

Hi @sharepointguy 

 

That's a very peculiar looking array of arrays!  An array of objects would be easier, saying that, this is possible with a select.

 

From: range(1,add(length(outputs('Compose')?['values']),-1))

which is basically skip integer 0 (the header) and run til length of values array minus 1

 

keys are:

outputs('Compose')?['values']?[0]?[0]
outputs('Compose')?['values']?[0]?[1]
values are:
outputs('Compose')?['values']?[item()]?[0]
outputs('Compose')?['values']?[item()]?[1]
 
I stuck your array into a compose
DamoBird365_1-1629318575876.png

 

and converted it as requested....

 
DamoBird365_0-1629318553158.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

Thank you so much. This was really helpful.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,014)