title: How to iterate this JSON Array using Java and org.json in Android?
body: <p>My JSON string looks like this (contained in a string variable called <code>sJSON</code>):</p>
  
  <pre><code>[
      {"id":284}
  ],
  [
      {"name":John,"surname":Doe},
      {"name":Jane,"surname":Doe}
  ]
  </code></pre>
  
  <p>I'm able to parse the first array like this (using Java and importing org.json):</p>
  
  <pre><code>JSONArray arrJSON = new JSONArray(sJSON);
  JSONObject jsonGeneralData = new JSONObject(arrJSON.get(0).toString());
  
  String sResult = jsonGeneralData.get("id").toString();
  </code></pre>
  
  <p>That returns the expected result, which is 284. I'm struggling to get the second array of items, and iterate through them. I'm not sure if my JSON string is malformed, or if I'm trying to access it the wrong way. Here's what I tried:</p>
  
  <pre><code>JSONObject jsonPersonData = new JSONObject(arrJSON.get(1).toString());
  </code></pre>
  
  <p>This is as far as I got, I can't figure out how to loop through the individual items inside the second array.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It seems that this line only parses the first string in the square brackets:</p>
  
  <pre><code>JSONArray arrJSON = new JSONArray(sJSON);
  </code></pre>
  
  <p>Either the JSON is wrong (same example as above), or it's not parsing it correctly? I've managed to solve the problem by doing a split on the string and put them each in their own <code>JSONArray</code>, but I don't think that's the best way of doing things.</p>