web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / JSON Iterating through...
Power Automate
Unanswered

JSON Iterating through an Array for specific values

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all, I'm trying to output just the 'answer' values that are found under 'subquestion' at the JSON here: https://gist.githubusercontent.com/alexgmartin/18c78881bdddcaee36743833cec36721/raw/1500bc78002cd7987870ff784e84aa603d3fb8f0/testing.json

 

I can ParseJSON and convert that Body to an array variable. But I don't know how to iterate through the array just to extract the values for 'answer'. Any help would be appreciated.

Categories:
  • JohnAageAnderse Profile Picture
    1,986 on at

    Hello @Anonymous 

     

    My guess is that your array has one item and in that one item is a another array - the "data" - which contains all the survey data.

     

    You will have to loop (apply to each) through both your one item and your "data" arrays. The inner loop (apply to each) for the "data" array will allow you to access the questions/answers. 

    Getting the first question and answer: item()?['survey_data']?['19']?['subquestions']?['20']?['question'] and item()?['survey_data']?['19']?['subquestions']?['20']?['answer']

     

    This you have to do for all your subquestions in the "data" using their respective paths!

    Hope this helps you on the way 🙂

    Kind regards, John

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @JohnAageAnderseIs there a way I can loop through it without specifying the ['19'] or ['20']? Something like iterate through all child elements..I dunno:/

  • JohnAageAnderse Profile Picture
    1,986 on at

    Hello @Anonymous 

     

    Did you find a solution for this yet? Anyway I found that using a Select action, it is possible to create an object with the questions and answers for easy use.

    With your JSON data element as input (From) to a Select action, you can then map each question and answer.

    JSON.Select.Map.jpg

    Each map needs a name (the question) and a value (the answer), so using expressions in both name and value field as follows:

    Name expression: item()?['survey_data']?['19']?['subquestions']?['20']?['question']

    Value expression: item()?['survey_data']?['19']?['subquestions']?['20']?['answer']

    This you do for all the questions/answers that you need.

     

    Note that under element "77", some of the questions are the same as under element "19", so I added "Contact " before the expression to avoid naming conflicts!

    Hope the above helps you 🙂

    Kind regards, John

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 132

Last 30 days Overall leaderboard