Android 改装-如何忽略表名
我正在尝试从API中获取一些项,如下所示:Android 改装-如何忽略表名,android,api,rest,retrofit,retrofit2,Android,Api,Rest,Retrofit,Retrofit2,我正在尝试从API中获取一些项,如下所示: { "picklist": [ { "name": "Abkhazia", "id": "a0511000002gxF1AAI" }, { "name": "Afghanistan", "id": "a0511000002gxF2AAI" }, { "name": "Akrotiri and Dhekelia", "id": "a0511000002gxF3AAI" }, { "name": "Albania", "id": "a0511000002
{ "picklist": [
{ "name": "Abkhazia", "id": "a0511000002gxF1AAI" },
{ "name": "Afghanistan", "id": "a0511000002gxF2AAI" },
{ "name": "Akrotiri and Dhekelia", "id": "a0511000002gxF3AAI" },
{ "name": "Albania", "id": "a0511000002gxF5AAI" },
{ "name": "Algeria", "id": "a0511000002gxF6AAI" },
{ "name": "American Samoa", "id": "a0511000002gxF7AAI" }
] }
我试着这样取:
public interface MyAPI {
@GET("/?country=true")
Call<List<User>> getUsers();
}
如何解决此问题?您应该使用自定义响应来解决此问题:
public interface MyAPI {
@GET("/?country=true")
Call<APIResponse> getUsers();
}
class APIResponse {
@JsonProperty("picklist") List<User> userList;
}
对于这种情况,您应该使用自定义响应:
public interface MyAPI {
@GET("/?country=true")
Call<APIResponse> getUsers();
}
class APIResponse {
@JsonProperty("picklist") List<User> userList;
}
使用url和参数在postman中添加用户entitycheck。您的url或服务器响应一定有问题。请使用url和参数在postman中添加用户entitycheck。您的url或服务器响应一定有问题。
class APIResponse {
List<User> picklist;
}