With retrofit I use a JsonArray, I want to get elements from the Json Objects list
this is my Json
{
"Codigo": 0,
"FechaHora": "2017-07-11T11:23:11",
"Mensaje": "Ok",
"Data": [
[
{
"Id": 1,
"Nombre": "Humanos",
"Estado": 1
}
],
[
{
"Id": 1,
"TDId": 1,
"GOId": 1,
"ImgId": null,
"Nombre": "Hola",
"Estado": 1
}
]
]
}
I want to get the Data Elements [] this is my Retrofit method
public void sincronizar() {
fecha = "1990-01-01T00:00:00";
final Object lista[] = new Object[1];
lista[0] = fecha;
parametroApi.setDatoG(lista);
PedroApi service = retrofit.create(PedroApi.class);
Call<Respuesta<JsonArray>> call = service.sincronizar(parametroApi);
call.enqueue(new Callback<Respuesta<JsonArray>>() {
@Override
public void onResponse(Call<Respuesta<JsonArray>> call, Response<Respuesta<JsonArray>> response) {
if (response.isSuccessful()) {
try {
Respuesta<JsonArray> respuesta = response.body();
if (respuesta.respuestaExitosa() == true) {
Log.e(TAG, "Respuesta Exitosa" + respuesta.toString());
String fechas = respuesta.getFechaHora();
//Try
//Insertar en BD
//Actualizar Token = fecha
//Cath
//NO dio
} else if (respuesta.respuestaExitosa() == false) {
Log.e(TAG, "Respuesta NO Exitosa" + respuesta.toString());
}
} catch (Exception e) {
Log.d(TAG, "Ocurio una Exepcion" + e.getMessage());
e.printStackTrace();
}
}
}
@Override
public void onFailure(Call<Respuesta<JsonArray>> call, Throwable t) {
Log.d(TAG, "Falla el consumo : " + t.getMessage().toString());
PopUp("Errorl al conectarse con el Servidor Por favor intetalo de nuevo");
}
});
}
this my Service
@POST("encuesta/sincronizar")
Call<Respuesta<JsonArray>> sincronizar(@Body ParametroApi<Object[]> parametroApi);
How can I walk the Data JsonObjects []?