title: How to access fields in JSON object by index
body: <p>I know this isn't the best way to do it, but I have no other choice :(</p>
  
  <p>I have to access the items in JSONObject by their index. The standard way to access objects is to just wirte <code>this[objectName]</code> or <code>this.objectName</code>. I also found a method to get all the fields inside a json object:</p>
  
  <pre><code>(for (var key in p) { 
    if (p.hasOwnProperty(key)) { 
      alert(key + " -&gt; " + p[key]); 
    } 
  } 
  </code></pre>
  
  <p>(Soruce : <a href="https://stackoverflow.com/questions/684672/loop-through-json-object">Loop through Json object</a>).</p>
  
  <p>However there is no way of accessing the JSONfields directly by a index. The only way I see right now, is to create an array, with the function above, get the fieldname by index and then get the value by fieldname.</p>
  
  <p>As far as I see it, the p (in our case the JSON file must be an iteratable array to, or else the foreach loop wouldn't work. How can I access this array directly? Or is it some kind of unsorted list?</p>