title: JSON - Iterate through JSONArray
body: <p>I have a JSON file with some arrays in it. I want to iterate through the file arrays and get their elements and their values.</p>
  <p><strong>This is how my file looks like:</strong></p>
  <pre><code>{
  &quot;JObjects&quot;: {
      &quot;JArray1&quot;: [
          {
              &quot;A&quot;: &quot;a&quot;,
              &quot;B&quot;: &quot;b&quot;,
              &quot;C&quot;: &quot;c&quot;
          },
          {
              &quot;A&quot;: &quot;a1&quot;,
              &quot;B&quot;: &quot;b2&quot;,
              &quot;C&quot;: &quot;c3&quot;,
              &quot;D&quot;: &quot;d4&quot;
              &quot;E&quot;: &quot;e5&quot;
          },
          {
              &quot;A&quot;: &quot;aa&quot;,
              &quot;B&quot;: &quot;bb&quot;,
              &quot;C&quot;: &quot;cc&quot;,
              &quot;D&quot;: &quot;dd&quot;
          }
  
      ]
  }
  
  }       
  </code></pre>
  <p><strong>This is how far I have come:</strong></p>
  <pre><code>JSONObject object = new JSONObject(&quot;json-file.json&quot;);
  JSONObject getObject = object.getJSONObject(&quot;JObjects&quot;);
  JSONArray getArray = getObject.getJSONArray(&quot;JArray1&quot;);
  
  for(int i = 0; i &lt; getArray.length(); i++)
  {
        JSONObject objects = getArray.getJSONArray(i);
        //Iterate through the elements of the array i.
        //Get thier value.
        //Get the value for the first element and the value for the last element.
  }
  </code></pre>
  <p>Is it possible to do something like this?</p>
  <p>The reason I want to do it like this is because the arrays in the file have a different number of elements.</p>