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 😘

Gexudo
Frequent Visitor

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (2,941)