Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 改装项目列表始终为空_Android_Json_Retrofit - Fatal编程技术网

Android 改装项目列表始终为空

Android 改装项目列表始终为空,android,json,retrofit,Android,Json,Retrofit,我试图从android应用程序上的WS获取项目列表,但响应总是空的 这是我的代码,我想不出来: 接口: public interface CategoriesInterface { @GET("/categories") List<CategorieModel> getCategories(@Query("k") String token); } @GET("/categories") CategorieContainer getCategories(@Query("

我试图从android应用程序上的WS获取项目列表,但响应总是空的

这是我的代码,我想不出来:

接口:

public interface CategoriesInterface {

   @GET("/categories")
   List<CategorieModel> getCategories(@Query("k") String token);
}
@GET("/categories")
CategorieContainer getCategories(@Query("k") String token);
响应JSON格式:

 "categories": [
    {
        "id": "2",
        "cat_pt": “STRING",
        "cat_es": “STRING"
    },
我不知道我做错了什么。响应列表始终为空


谢谢

您的JSON返回一个CategoryContainer,其中包含一个CategorieModel数组。添加新的模型类:

public class CategorieContainer {
    private List<CategorieModel> categories = new ArrayList<>();
    // TODO Getter / Setter
}

当您在浏览器中实际访问该url时,会得到什么?有数据吗?“WS_URL”是正确的URL吗?URL是正确的,克里斯托弗·贝娄的回答很好。无论如何谢谢你谢谢你!工作完美
public class CategorieContainer {
    private List<CategorieModel> categories = new ArrayList<>();
    // TODO Getter / Setter
}
@GET("/categories")
CategorieContainer getCategories(@Query("k") String token);