cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JmeBrey
Frequent Visitor

How to drill into JSON

Hi Everyone

 

I am using a HTTP request and after using parse JSON to get the following.

 

 

{
  "body": {
    "Members": {
      "Member": [
        {
          "@Member_Id": "172",
          "DisplayAs": "user 1",
          "Gender": "F",
          "CurrentStatus": {
            "StartDate": "2019-12-12T00:00:00"
          },
          "Addresses": {
            "Address": [
              {
                "@Type_Id": "6",
                "Address1": "http://www.google.com"
              },
              {
                "@Type_Id": "1",
                "Email": "user1@gmail.uk",
                "OtherAddress": null
              }
            ]
          }
        },
        {
          "@Member_Id": "172",
          "DisplayAs": "user 2",
          "Gender": "M",
          "CurrentStatus": {
            "StartDate": "2019-05-12T00:00:00"
          },
          "Addresses": {
            "Address": [
              {
                "@Type_Id": "6",
                "Address1": "http://www.bing.com"
              },
              {
                "@Type_Id": "1",
                "Email": "user2@hotmail.com",
                "OtherAddress": null
              }
            ]
          }
        }
      ]
    }
  }
}

 

 
I am trying to get the email addresses but in all my attempts I get the same error...

 

json1.pngjson2.png


How would I drill into the response and get the email addresses for both users?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

You should select 'Member', not addresses.  You use an index to get the specific address you want from the addresses array.  see the screenshot below.

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.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User III
Dual Super User III

After you parse the JSON add the Address dynamic content to an Apply to Each loop to loop through the addresses.  The email is in the second entry of the address array in your sample.  Assuming it always is you can get the email from the array inside the loop using the following.

items('Apply_to_each')?['Addresses']?['Address'][1]?['Email']


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

Thanks for the response.

 

Unfortunately If I add a apply to each loop under the Parse JSON and select 'Address' the Flow automatically places that as a nested loop in another apply to each loop of 'Member' (apply to each 2 is the auto generated loop added by Flow)

 

json3.png

 

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['Members']?['Member']' is of type 'Null'. The result must be a valid array.

 

 

I get the same error saying that something is null. I can clearly see the data from the HTTP request and the JSON after it is parsed so I don't understand why it would be saying something is null.

Pstork1
Dual Super User III
Dual Super User III

You should select 'Member', not addresses.  You use an index to get the specific address you want from the addresses array.  see the screenshot below.

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.

View solution in original post

JmeBrey
Frequent Visitor

Thank you so much for your help, I really appreciate it as I was so stuck. It worked and I can continue building the flow.

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (30,830)