简体   繁体   English

Retrofit2,Android,对数组进行@Get解析

[英]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 Retrofit call. 这是两个对象,示例响应和我的Retrofit调用。 Please help me access this string. 请帮助我访问此字符串。

response pojo: 响应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;
}

Retrofit 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].getInvisible(); 我尝试使用result[i].Details[0].getInvisible();

but my error response is: 但是我的错误响应是:

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

Thank you for reading. 感谢您的阅读。

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

Then 然后

results[i].getarr[0].getfindMe();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM