I'm trying get a JSONObject from a JSONArray. When I do Log.i display values of JSONArray and has JSONObject that I want. The problem is when I try get this JSONObject, throws an exception show: No value for Local or No value for TipoLocal. Local and TipoLocal are JSONObject into JSONArray.
How could I do it ?
JSON
{"Retorno":[
{"Local":{"id":"1","nome":"Vovo Landa","telefone":"3333333","celular":"44444","endereco":"Rua 46 a","numero":"025","bairro":"bairro","email":"email"}},
{"TipoLocal":{"id":"1","tipo":"Pizzaria"}}
]}
JSONObject
try{
Gson gson = new Gson();
JSONArray retorno = obj.getJSONArray("Retorno");
if(retorno.length() > 0){
for(int x = 0; x < retorno.length(); x++){
JSONObject jsoObject = retorno.getJSONObject(x);
JSONObject jsoLocal = jsoObject.getJSONObject("Local");
JSONObject jsoTipoLocal = jsoObject.getJSONObject("TipoLocal");
}
}
}catch (JSONException e) {
Log.e("JSONException->:", "getLocais in LocalDAO: " + e.getLocalizedMessage());
}