Skip to main content

Notifications

Community site session details

Community site session details

Session Id : jT19L4EPmQsDxtUyqTgX3V
Power Automate - General Discussion
Answered

Iterate through a Json array?

Like (2) ShareShare
ReportReport
Posted on 4 Mar 2021 16:57:43 by 87

Hello there,

 

I have a Json structure like that

 


[
 {
  "ColumnID": "1",
  "Column1": "Main directory1",
  "Column2": "Sub directory1",
  "Column3": "Documents1",

 },

 {
  "ColumnID": "2",
  "Column1": "Main directory2",
  "Column2": "Sub directory2",
  "Column3": "Documents2",

 },

 {
  "ColumnID": "3",
  "Column1": "Main directory3",
  "Column2": "Sub directory3",
  "Column3": "Documents3",

 },
]

 


I would like to iterate through it so that at each iteration I read the following values:
First iteration: Main directory1
Second iteration: Main directory2
Third iteration: Main directory3


What I did until now? I declared a variable iteratorRow that starts from 1, I filter the array to get the #iteratorRow location, I compose it to get the single array (and not the object), I compose it again to get the single value.

This flow is working if I am not using "Do until" and I want to get a single value of the Json array.

 

image.png

 

 

The big problem is the "Step1 Filter array" action. It can not get a variable on the right, it must be a string. This is driving me insane.
-I try to edit in advance mode like this: "@equals(item()?['ColumnID'], variables('iteratorRow'))" but nothing.
-I try to build a string with the value of iteratorRow and then concat a series of variable to have something like this @equals(item()?['ColumnID'], 'theActualIteratorRow'  but I cant pass a variable in advance edit.

Do you have a solution or workaround to this problem? 

  • ChrisMendoza Profile Picture
    425 on 08 Sep 2021 at 18:00:13
    Re: Iterate through a Json array?

    @dignus93reply- I know I'm late to the party here however, I had a similar need and I solved as:

    items('Apply_to_each')?['Column1']

     

    image.png

    image.png

  • HEATFreight Profile Picture
    1,020 on 07 Sep 2021 at 21:34:40
    Re: Iterate through a Json array?

    Yo @dignus93reply, just to update you on my progress... I am now nesting Parse JSON actions within each other to parametrically grab specific attributes and populate them into arrays for later processing, all thanks to your solution!

    The more I think about it, the more I think nesting them may be unnecessary, because by it's very nature the Parse JSON action should make all of the properties accessible if the right schema is used, but it's not always easy to code working logic with such a massive set of dynamic content, so a nested pair of Parse JSON actions has proven extremely powerful in my use case, and it would not be possible without your little trick!

  • HEATFreight Profile Picture
    1,020 on 29 Aug 2021 at 22:44:02
    Re: Iterate through a Json array?

    holy smokes @dignus93reply you just saved me from the counter-variable apocalypse!

    I did exactly what you said and now I am able to fully parameterize files using Parse JSON and no counters!

    Thanks brother, I owe you one👆

  • Verified answer
    dignus93reply Profile Picture
    87 on 17 Mar 2021 at 16:01:03
    Re: Iterate through a Json array?

    Thanks for all the good advice folks.

     

    I solved like this: I declare the json array in a string variable. I parse it in Json. In the parse JSON action I click "generate from sample" and I paste the json array. It will generate automatically a schema. Then I loop through it with an Apply to each. In the "select an output from previous steps" of the apply to each I chose the Body of the parse JSON. Inside I read the Column1.

     

    Finally I can get my desired output
    "Main directory1" at iteration1;

    "Main directory2" at iteration2;

    "Main directory3" at iteration3

    s1.png

     
  • mahoneypat Profile Picture
    1,720 on 05 Mar 2021 at 01:40:03
    Re: Iterate through a Json array?

    Why not just use an Apply To Each on your array instead of Do Until?

    Pat

  • jinivthakkar Profile Picture
    4,179 on 04 Mar 2021 at 17:17:24
    Re: Iterate through a Json array?

    @dignus93reply I found a similar thread here :

     

    https://powerusers.microsoft.com/t5/Building-Flows/Convert-JSON-array-to-string-array/m-p/395040

     

    https://powerusers.microsoft.com/t5/General-Power-Automate/For-each-sum-JSON-array/m-p/557499

     

     

    --------------------------------------------------------------------------------

    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - General Discussion

#1
ankit_singhal Profile Picture

ankit_singhal 5 Super User 2025 Season 1

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 4 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 2 Super User 2025 Season 1

Overall leaderboard