title: how to parse a json with android
body: <p>Hello all i have a problem with a special json formatted with an array of array and object.</p>
  
  <pre><code>{
    "contrat":  [
      {
        "id":0,
        "email":"RAJita@YAHOO.COM",
        "mobile":"55281055",
        "fixe":"33740970",
        "numContrat":"252010176",
        "offre":"bb : Automobile",
        "dateDebut":"2013-01-03",
        "dateFin":"2014-01-03",
        "statut":"En cours"
      },
      [ ],
      [ ]
    ],
    "success":1,
    "code":200
  }
  </code></pre>
  
  <p>Normally if I had a normal json with an array of object, I used this method:</p>
  
  <pre><code>JSONArray contratObj = json.getJSONArray("contrat"); // JSONArray
  for (int i = 0; i &lt; contratObj.length(); i++) {
      // get first contrat object from JSON Array
      JSONObject contrat = contratObj.getJSONObject(i);               
  
      contratlist.add(new contratitem(contrat.getInt("id"),
      contrat.getString("numContrat"), contrat.getString("offre"), 
      contrat.getString("dateDebut"), contrat.getString("dateFin"), 
      contrat.getString("statut")));
  }
  </code></pre>
  
  <p>but the array "contrat" contains empty array and object</p>
  
  <p><strong><em>How can I change my code to ignore empty array ?</em></strong></p>