Skip to content
Advertisement

Retrofit2, Android, @Get Parsing for the Array of Array

I am parsing the title correctly and displaying it in a listview. I cant seem to access the

String findMe;

seen below. Here are the two objects, sample response and my call.

response pojo:

public class Response {
     public String count;
     public  Result []results;
}

first object

public class Result {
     public String title;
     public static arr [] Details;

second object

public class Details   {
     public Integer _id;
     public String findMe;
}

response:

Call<Response> call = api.getListWith(API_KEY);
    call.enqueue(new Callback<Response>() {
        @Override
        public void onResponse(Call<Response> call, Response<Response> response) {
            result = response.body();
}

I am getting the title just by passing ‘result’ into the adapter and using

result[i].getTitle();

I tried using result[i].Details[0].findMe;

but my error response is:

 java.lang.NullPointerException: Attempt to read from null array

Advertisement

Answer

public class Result {
    public String title;
    public Details[] arr;
}

Then

results[i].getarr[0].getfindMe();
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement