cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenDonahue
Skilled Sharer
Skilled Sharer

Accessing values in json object using index

I wish to access the answers in a response object by using their index.

I saw a response by @Pstork1 where he mentioned doing exactly that. I was hoping someone could describe how that is accomplished.

For reference, here is the object in question:

{
  "responder""BDonahue@healthcareswfl.org",
  "submitDate""10/2/2020 6:02:14 PM",
  "raf03b7b3e8054666b737a20e30d25abf""",
  "r71b19e7c5beb4dba95fee5e9d9578bc2""No",
  "r4da533c8aeb3472aacd19c2f1250e75c""",
  "r53d3e3791038471f894029c5634d8e6d""No",
  "r2efc3356f5064729b0f186e7f6b5b52d""No",
  "rb7dbfe7ca0cc4b25a1cf659414fff419""No",
  "r014fe8a6004b46dbb1dbed880968ca79""No",
  "r20d0ef76e51e426f8911d0d7ce2e272e""",
  "rb906a66fb83c449ca1d0e35c427f3a02""13",
  "r24be9a1ba7f9468fae16b296331d4c25""",
  "r0184384dd0c44d88af36051a758ba5aa""No",
  "r8b337663cc03426c92704ccd813be3b8""No",
  "rdf04e95ac19042a5894ca0f7b35292d0""",
  "r23ebfc6e6b8d4729923867b8e6ebd548""No",
  "r7486d8f749194143a405d901c0099799""",
  "r48c1c4e8093743ed92d8e9fb9a9a2978""s1 notes",
  "r92b84414bcdd47e1a81bd7e3fa4245e4""s2 notes",
  "r745fad073e1745d0a0d5edf25e7d2fb0""s3 notes"
}

Thank you for your help.

1 ACCEPTED SOLUTION

Accepted Solutions

I don't know of any way to get the properties of an object(JSON) converted into an array.  But the properties should be in the same order each time for a particular survey form and the keys will always match to each question.  I would suggest running the survey once to find out what the keys for each question are and then creating an Excel table with the questions and the corresponding key.  Then you should be able to access the answers from the JSON using the keys.

 

The only time looping would be involved would be to process multiple responses from different people.  Then you would have an array of objects like the one you listed in your first question.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
Pstork1
Dual Super User
Dual Super User

Unfortunately, that's not an array, so there is no way to access those properties by a numeric index.  But you can load it into a Parse Json action and access the properties directly by name.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you, @Pstork1 , for your quick reply. Perhaps I should describe what I am hoping to do in better detail.

With 40-90  questions to deal with, I am hoping to have a list of those questions that exactly matches the content and order of the questions on the Forms Pro form (which I am re-creating so the JSON will have the responses in order, too).

Having established that, I am further hoping to populate emails with the questions and responses dynamically. My strat on this is to have two arrays, one that is populated from an Excel table, and one that is populated from the "Get response details" outputs.

Then, utilizing an incrementing variable, use that variable to access the index of each array to populate the email body.

arrQuestions[(variables('intIndex'))]: arrAnswers[(variables('intIndex'))]   (or something to that effect)

Assuming any of this makes sense, would you mind helping me accomplish this? I believe all I need is to get the responses into an array, which escapes me.

Thank you, again; your help is greatly appreciated.

I don't know of any way to get the properties of an object(JSON) converted into an array.  But the properties should be in the same order each time for a particular survey form and the keys will always match to each question.  I would suggest running the survey once to find out what the keys for each question are and then creating an Excel table with the questions and the corresponding key.  Then you should be able to access the answers from the JSON using the keys.

 

The only time looping would be involved would be to process multiple responses from different people.  Then you would have an array of objects like the one you listed in your first question.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Would I be able iterate over the JSON and somehow access the answer at each iteration and append that to an array variable?

I'm not aware of any way to do that with the different properties in the object.  Each property is addressed by name.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 ,

It took a night's sleep, but I finally woke up to the realization of what you are saying; having an array of the question codes is as good as having an array of the answers, in this case. 

Thank you for your help and patience with me.

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!

Users online (2,269)