title: Count and loop through JSON object of arrays
body: <p>I get issues when I want to loop through a JSON array of objects.</p>
  
  <p><strong>Issues such as:</strong></p>
  
  <ul>
  <li>It only counts two (I assume because of they Object.keys) and I have two keys.</li>
  <li>Loops with only one value</li>
  </ul>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>var codes = require('./nl.json');
  for (var i = 0, l = Object.keys(codes).length; i &lt;= l; i++) {
      console.log(l) ;
      var areaCodeTest = codes.netherlands[i].areaCode;
      var areaNameTest = codes.netherlands[i].areaName;
  
      it("Search for postal code ", function(){
          var postCode = element(by.id("imysearchstring"));
          postCode.click(); 
          browser.sleep(1000); 
          console.log(areaCodeTest);
          postCode.clear().sendKeys(areaCodeTest);
          browser.sleep(1000);
          console.log("Typed " + areaCodeTest);
      });
  }
  </code></pre>
  
  <p><strong>My Json (Short example):</strong></p>
  
  <pre><code>{
  "netherlands": [
    {
      "areaCode": 9401,
      "areaName": "Assen"
    },
    {
      "areaCode": 9402,
      "areaName": "Assen"
    },
    {
      "areaCode": 9403,
      "areaName": "Assen"
    }
   ]
  }
  </code></pre>
  
  <p>I have looked at answers such as :</p>
  
  <p><a href="https://stackoverflow.com/questions/6756104/get-size-of-json-object/6756305">Size of Object</a> and
  <a href="https://stackoverflow.com/questions/15209136/how-to-count-length-of-the-json-array-element">Length of Json</a></p>
  
  <p><strong>I have tried:</strong></p>
  
  <pre><code>(var i = 0, l = Object.keys(codes).length; i &lt;= l; i++)
  
  (var i = 0, l = Object.keys(codes.netherlands[0]).length; i &lt;= l; i++)
  
  for (var i = 0, l = codes.netherlands.length; i &lt;= l; i++) // uses last areaCode in json file and only loop with that number. It does not start from top.
  </code></pre>
  
  <p><strong>Image:</strong>
  <a href="https://i.stack.imgur.com/kxTWR.jpg" rel="nofollow noreferrer">some of my outputs</a></p>
  
  <p><strong>Expected:</strong>
  What I want is to count amount of ofjects in JSON (Not the key/values)</p>
  
  <p>Loop through all data and assign them to <code>var areaCodeTest = codes.netherlands[i].areaCode;</code> and <code>var areaNameTest = codes.netherlands[i].areaName;</code></p>