title: Valid JSON throwing JSONArray[0] is not a JSONObject
body: <p>I have valid JSON as validated by <a href="https://jsonlint.com/" rel="nofollow noreferrer">JSONLint</a> and <a href="https://jsonformatter.curiousconcept.com/" rel="nofollow noreferrer">JSON Formatter and Validator</a>.  I have seen the other posts on SO like:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/39139708/org-json-jsonexception-jsonarray0-is-not-a-jsonobject">org.json.JSONException: JSONArray[0] is not a JSONObject</a></li>
  <li><a href="https://stackoverflow.com/questions/33471264/jsonarray0-is-not-a-jsonobject-exception">JSONArray[0] is not a JSONObject exception</a></li>
  </ul>
  
  <p>The code to extract the JSON is such:</p>
  
  <pre><code>JSONObject jsonObject = new JSONObject(strData);
  JSONArray jsonADSArray = jsonObject.getJSONArray("advance_purchases");
  int i = 0;
  while(i &lt; jsonADSArray.length()){
  
      JSONObject obj = jsonADSArray.getJSONObject(i);
  
  }
  </code></pre>
  
  <p>The line:</p>
  
  <pre><code>JSONObject obj = jsonADSArray.getJSONObject(i);
  </code></pre>
  
  <p>Throws the error:</p>
  
  <pre><code>JSONArray[0] is not a JSONObject
  </code></pre>
  
  <p>where strData passed in using REST POST:</p>
  
  <pre><code>{
      "advance_purchases": [
          "{ \"_id\":40, \"cancel_date\":1585760255892, \"cancel_user\":\"FACTORY\", \"create_date\":1585760206434, \"create_user\":\"FACTORY\", \"purchase_date\":1585918800000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":53, \"cancel_date\":1585921300976, \"cancel_user\":\"Shipped\", \"create_date\":1585914517011, \"create_user\":\"FACTORY\", \"purchase_date\":1585918800000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":54, \"cancel_date\":1585945994083, \"cancel_user\":\"Shipped\", \"create_date\":1585914517021, \"create_user\":\"FACTORY\", \"purchase_date\":1585929600000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":41, \"cancel_date\":1585760255920, \"cancel_user\":\"FACTORY\", \"create_date\":1585760207083, \"create_user\":\"FACTORY\", \"purchase_date\":1586005200000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":42, \"cancel_date\":1585760255932, \"cancel_user\":\"FACTORY\", \"create_date\":1585760207093, \"create_user\":\"FACTORY\", \"purchase_date\":1586016000000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":56, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585921279663, \"create_user\":\"FACTORY\", \"purchase_date\":1586005200000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":57, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585921279685, \"create_user\":\"FACTORY\", \"purchase_date\":1586016000000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":43, \"cancel_date\":1585861077997, \"cancel_user\":\"Purchase Changed\", \"create_date\":1585760207724, \"create_user\":\"FACTORY\", \"purchase_date\":1586091600000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":44, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585860099795, \"create_user\":\"FACTORY\", \"purchase_date\":1586102400000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":55, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585914513604, \"create_user\":\"FACTORY\", \"purchase_date\":1586091600000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":45, \"cancel_date\":1585861078013, \"cancel_user\":\"Purchase Changed\", \"create_date\":1585860109341, \"create_user\":\"FACTORY\", \"purchase_date\":1586178000000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":46, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585860109353, \"create_user\":\"FACTORY\", \"purchase_date\":1586188800000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":58, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585921275924, \"create_user\":\"FACTORY\", \"purchase_date\":1586178000000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":47, \"cancel_date\":1585861078023, \"cancel_user\":\"Purchase Changed\", \"create_date\":1585860107142, \"create_user\":\"FACTORY\", \"purchase_date\":1586264400000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":48, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585860107157, \"create_user\":\"FACTORY\", \"purchase_date\":1586275200000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":59, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585921275944, \"create_user\":\"FACTORY\", \"purchase_date\":1586264400000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":49, \"cancel_date\":1585861078031, \"cancel_user\":\"Purchase Changed\", \"create_date\":1585860105853, \"create_user\":\"FACTORY\", \"purchase_date\":1586350800000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":50, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585860105865, \"create_user\":\"FACTORY\", \"purchase_date\":1586361600000, \"purchase_id\":729, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":60, \"cancel_date\":0, \"cancel_user\":\"\", \"create_date\":1585921275964, \"create_user\":\"FACTORY\", \"purchase_date\":1586350800000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":51, \"cancel_date\":1585861078040, \"cancel_user\":\"Purchase Changed\", \"create_date\":1585860137954, \"create_user\":\"FACTORY\", \"purchase_date\":1586437200000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }",
          "{ \"_id\":52, \"cancel_date\":1585861078049, \"cancel_user\":\"Purchase Changed\", \"create_date\":1585860138874, \"create_user\":\"FACTORY\", \"purchase_date\":1586523600000, \"purchase_id\":728, \"rejected\":0, \"remote_id\":-1, \"synced\":0 }"
      ]
  }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>jsonADSArray.length()
  </code></pre>
  
  <p>returns 21</p>
  
  <blockquote>
    <p>Since the JSON has been validated, why is the code throwing an error?</p>
  </blockquote>