title: How to loop through an array in a logic app?
body: <p>I have managed to get all my userdata in an array (see <a href="https://stackoverflow.com/questions/59107093/how-to-store-all-azure-ad-user-group-members-in-an-array-using-a-logic-app">here</a>) but now I cannot loop through the data. After building the array I have converted it to JSON, but I can no longer address the fields as defined in my JSON schema.</p>
  
  <p>The only thing I can address in my loop (I use the JSON body as input for the For Each loop) is the body itself, not the individual fields like username, mail address etc. </p>
  
  <p>Should I change something in my JSON schema to overcome this or is something else wrong?</p>
  
  <p>Edit: Please find my JSON schema below:</p>
  
  <pre><code>   {
         "$schema": "http://json-schema.org/draft-04/schema#",
         "items": [
             {
                 "properties": {
                     "@@odata.type": {
                         "type": "string"
                     },
                     "createdDateTime": {
                         "type": "string"
                     },
                     "employeeId": {
                         "type": "string"
                     },
                     "givenName": {
                         "type": "string"
                     },
                     "id": {
                         "type": "string"
                     },
                     "mail": {
                         "type": "string"
                     },
                     "onPremisesSamAccountName": {
                         "type": "string"
                     },
                     "surname": {
                         "type": "string"
                     },
                     "userPrincipalName": {
                         "type": "string"
                     }
                 },
                 "required": [
                     "@@odata.type",
                     "id",
                     "givenName",
                     "surname",
                     "userPrincipalName",
                     "mail",
                     "onPremisesSamAccountName",
                     "employeeId",
                     "createdDateTime"
                 ],
                 "type": "object"
             }
         ],
         "type": "array"
     }
  </code></pre>
  
  <p>Please see the image for how the JSON looks: </p>
  
  <p><img src="https://i.stack.imgur.com/HeNEO.png" alt="JSON Schema"></p>