[Item {parent ='0',iD ='0',menu ='null'},Item {parent ='0',iD ='0',menu ='null'},Item {parent = '0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0 ',menu ='null'},项目{parent ='0',iD ='0',menu ='null'},Item {parent ='0',iD ='0',menu ='null'} ,Item {parent ='0',iD ='0',menu ='null'},Item {parent ='0',iD ='0',menu ='null'},Item {parent ='0' ,iD ='0',menu ='null'},项目{parent ='0',iD ='0',menu ='null'},Item {parent ='0',iD ='0',menu ='null'},项目{parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{ parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',menu ='null'},项目{parent ='0',iD = '0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null '},项目{parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{parent =' 0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{pa租金='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD = '0',菜单='null'},项目{parent ='0',iD ='0',菜单='null'},项目{parent ='0',iD ='0',菜单='null '},Item {parent ='0',iD ='0',菜单='null'},Item {parent ='0',iD ='0',菜单='null'}]
我练习了很多次翻新,但是这次我从翻新中得到了意外的答案。我检索到的列表充满了零和空参数。
有人可以帮助我吗?
//here is the my RestApi interface
@GET("api.ashx?getMenu=0")
Call<List<Item>> getAllResult();
@GET("api.ashx")
Call<List<Item>> getTinyResult(@Query("getMenu") String parentId);
// here is the my retrofitClient
private RestApi mRestApi;
public RestApiClient(String apiUrl){
OkHttpClient.Builder builder=new OkHttpClient.Builder()
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30,TimeUnit.SECONDS)
.connectTimeout(30,TimeUnit.SECONDS);
OkHttpClient okHttpClient=builder.build();
Gson gson = new GsonBuilder()
.setLenient()
.create();
Retrofit retrofit=new Retrofit.Builder()
.baseUrl(apiUrl)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
mRestApi = retrofit.create(RestApi.class);
}
public RestApi getRestApi(){
return mRestApi;
}
答案 0 :(得分:0)
是否可以发布您的 Logcat 内容?恐怕您可能有连接问题,或者您分配了未更正的字段,从而使您无法从 OkHTTP 报告获取值?
答案 1 :(得分:0)
该模型的字段缺少必需的注释,因此无法进行映射。
class Item {
@SerializedName("parent")
private int parent;
@SerializedName("id")
private int id;
@SerializedName("menu")
private String menu;
...
}