Estoy haciendo una consulta a un api que este me regresa la info, pero al querer agregarlo a un listview este me regresa que no se puede convertir...
La estructura que utilizo en el json es
{
"data": [
{
"ClaveTractor": "xxxx",
"Placas": "30-EN-5E",
"Caja": "0",
"NombreChofer": "xxxxxxxxxxxx",
"TipoViaje": "LOCALES",
"Cliete": "SEWS",
"Coordinador": "xxxxxxxxxxxx",
"FechaAlta": "2020-09-10T12:11:39.767Z",
"Celular": "xxxxxxxxx"
},
{
"ClaveTractor": "xxx",
"Placas": "30-EN-5E",
"Caja": "LAN73732",
"NombreChofer": "xxxxx",
"TipoViaje": "LOCALES",
"Cliete": "SEWS",
"Coordinador": "xxxxxxx",
"FechaAlta": "2020-09-10T09:24:26.970Z",
"Celular": "xxxxxxxx"
}
]
}
ya tengo el controller y el dataset y con este codigo es el que trato de agregarlo
JsonArrayRequest billionaireReq = new JsonArrayRequest(path, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
JSONObject jsonObject = response.getJSONObject(Integer.parseInt("data"));
Iterator<?> keys = jsonObject.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
if (jsonObject.get(key) instanceof JSONObject) {
JSONObject obj = (JSONObject) jsonObject.get(key);
DataSet dataSet = new DataSet();
dataSet.setCliente(obj.getString("Cliente"));
dataSet.setNombreChofer(obj.getString("NombreChofer"));
dataSet.setCoordinador(obj.getString("Coordinador"));
dataSet.setClaveTractor(obj.getString("ClaveTractor"));
dataSet.setPlaca(obj.getString("Placas"));
dataSet.setCaja(obj.getString("Caja"));
dataSet.setFecha(obj.getString("FechaAlta"));
dataSet.setTipoViaje(obj.getString("TipoViaje"));
dataSet.setNumero(obj.getString("Celular"));
list.add(dataSet);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
adapter.notifyAll();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
AlertDialog.Builder add = new AlertDialog.Builder(getActivity());
Log.d("error", error.getMessage());
add.setMessage(error.getMessage()).setCancelable(true);
AlertDialog alert = add.create();
alert.setTitle("Error!!");
alert.show();
}
});
Controller.getPermission().addToRequestQueue(billionaireReq);
}
});
Integer.parseInt("data")
? En todo caso está claro que te falla ANTES de esa línea (porque esa instrucción seguro que te lanza un NumberFormatException), así que es probable que te falle antes de invocar el código porque Android no puede hacer una conversión.