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/1500bc78002cd798...
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.
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
@JohnAageAnderseIs there a way I can loop through it without specifying the ['19'] or ['20']? Something like iterate through all child elements..I dunno:/
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.
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
Check out the News & Announcements to learn more.
Check out the new Power Platform Community Connections gallery!
Congratulations, the new Super User Season 2 for 2021 has started!
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.