I have a Power Automate flow that parses a JSON file and at some point I want to loop through a number of array elements that have a common structure like the sample below (NOTE: every parent element "Fo…" has a different name)
In my Power Automate flow there are several steps that extract only the part of the whole JSON file that contains the above structure elements. Using the xpath method I save the output to the variable varXML and I loop through its contents
Here is a more detailed view of the executed flow with input/output data
What I would like is inside the Compose – product_name step to get the value of product_name from the Compose – Add body step from each iteration of the loop. The tricky part that I am stuck here, is to use some sort of a wildcard for any "body/f***" element, in order to get to the rest of the nested elements below, like the product_name, service_name, link, etc. Thank you in advance 🙂
2
Answers
Since you have it as XML already, then you don’t need to switch back to JSON.
In your
Apply to each
, try the following in a Compose:and
The Advanced Data Operations connector and the Json Properties To Name Value Pair Array operation will do this for you standing on its head.
If you pass it this JSON …
… it will produce this result …
… that will allow you to loop through the top level set of properties, get the name of each one and then dynamically extract the data from the original object.
https://statesolutions.com.au/json-properties-to-name-value-pair-array/
https://statesolutions.com.au/trial-licence-sign-up/
Result