Hello all i have a problem with a special json formatted with an array of array and object.
{
"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
}
Normally if I had a normal json with an array of object, I used this method:
JSONArray contratObj = json.getJSONArray("contrat"); // JSONArray
for (int i = 0; i < 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")));
}
but the array "contrat" contains empty array and object
How can I change my code to ignore empty array ?