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

Converting Object to array so I can iterate over

Hello, 

 

I have been trying several approaches for this but so far I haven't been able to find a working solution, the object is as follows:

 

{
"responder": "email@email.pt",
"submitDate": "8/3/2021 4:20:00 PM",
"ra7992b65ed8447a4a1876f5208aee8bc": "Session1",
"r87015f835f094985908684447fcc9533": "Session2",
"r480746f9f54640be8c76d998e1892e02": "Session3",
"r99d5fa99223b453f804a51b95ffa2c09": "Session4"
}

 

 

What I am trying to do is just convert this into an array without the responder or the submitDate, any ideas / tips would be appreciated!

 

Edit 1 (For future references): My idea was to make a power autoamte that is resuable to any MS form (that has a specific template) without having to hard-code convert the json answers into an Array.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

You can do it like this:

2021-08-06_10-01-08.png

The output generated is:

[
  "Session1",
  "Session2",
  "Session3",
  "Session4"
]

The expression in Compose 2 is:

xpath(xml(json(concat('{ "values": ', removeproperty(removeProperty(outputs('Compose'), 'responder'), 'submitDate'), '}'))), '/values/*/text()')

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

View solution in original post

6 REPLIES 6
Paulie78
Super User
Super User

Can you just manually type what output you are looking to create please?

ekarim2020
Super User
Super User

It looks like you are processing MS Forms data. The response data will be available to you as dynamic content.

As @Paulie78 you can manually create the array. For example:

ekarim2020_0-1628018650329.png

ekarim2020_3-1628018985220.png

ekarim2020_2-1628018834694.png

Ellis

v-bofeng-msft
Community Support
Community Support

Hi @Gexudo :

I've made a test for your reference:

vbofengmsft_1-1628216322740.png

The Result:

vbofengmsft_0-1628216227244.png

Best Regards,

Bof

Gexudo
Frequent Visitor

Hi everyone, thank you for the great replies and suggestions!

 

However they are all a bit hard coded, my idea is to transform every answer of a specific forms template that we use into an array, without having to "hard-code" reference them in the array. The idea is to make this as easy to replicate to use with different forms which have the same template. And in doing so without the "hard-code" references, minimal change when replicating the flow would be needed.

Paulie78
Super User
Super User

You can do it like this:

2021-08-06_10-01-08.png

The output generated is:

[
  "Session1",
  "Session2",
  "Session3",
  "Session4"
]

The expression in Compose 2 is:

xpath(xml(json(concat('{ "values": ', removeproperty(removeProperty(outputs('Compose'), 'responder'), 'submitDate'), '}'))), '/values/*/text()')

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

Exactly what I was looking for! Thank you very much!

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.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,489)