Java 未获得预期的正确json响应实际响应

Java 未获得预期的正确json响应实际响应,java,android,json,retrofit2,Java,Android,Json,Retrofit2,这是我的代码,实际响应和预期响应完全不同。谁能查出我的错误,提前谢谢 主要活动 final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.movies_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(this)); ApiInterface apiService =

这是我的代码,实际响应和预期响应完全不同。谁能查出我的错误,提前谢谢

主要活动

        final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.movies_recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        ApiInterface apiService =
                ApiClient.getClient().create(ApiInterface.class);

        Call<List<UserModel>> call = apiService.getUserInfo();

        call.enqueue(new Callback<List<UserModel>>() {
            @Override
            public void onResponse(Call<List<UserModel>> call, Response<List<UserModel>> response) {
                int statusCode = response.code();
                List<UserModel> rs = response.body();
                Log.i("xxxxxxggggxxxxxxxxxxx",rs+"");

            }

            @Override
            public void onFailure(Call<List<UserModel>> call, Throwable t) {

            }
        });





usermodel 


    public class UserModel {

        @SerializedName("profile")
        @Expose
        private Profile profile;

        public Profile getProfile() {
            return profile;
        }

        public void setProfile(Profile profile) {
            this.profile = profile;
        }

    }

profile  

    public class Profile {


        @SerializedName("isActive")
        @Expose
        private Boolean isActive;
        @SerializedName("name")
        @Expose
        private Name name;




        public Boolean getIsActive() {
            return isActive;
        }

        public void setIsActive(Boolean isActive) {
            this.isActive = isActive;
        }

        public Name getName() {
            return name;
        }

        public void setName(Name name) {
            this.name = name;
        }

    }
ApiCLIENT

public interface ApiInterface {
    @POST("test")
    Call<List<UserModel>> getUserInfo();

}
这是我收到的响应
info.androidhive.reformation.model。UserModel@9c6c34c

这是我的代码,实际响应和预期响应完全不同。谁能查出我的错误,提前谢谢

这是我收到的回复info.androidhive.reformation.model。UserModel@9c6c34c

当然,当您试图打印响应的主体时,您将有这种类型的日志,因为您试图打印对象列表,即
list

因此,如果你想检查你收到的东西,你可以检查计数,如

Log.i("xxxxxxggggxxxxxxxxxxx",""+rs.size());

如果需要JSON对象,则应在界面中添加
@Headers
标记

e、 g

@Headers(“内容类型:application/json”)
@获取(“alluser/{iD}”)
调用doesUserExists(@Path(“iD”)字符串iD);
此外,还必须解析响应或将其转换为可以操纵的对象

@Override
public void onResponse(Call<String> call, Response<String> response) {
    if(response.body() != null){
        JsonParser parser = new JsonParser();
        JsonElement element = parser.parse(response.body());
        if(!element.isJsonNull()){
            JsonObject obj;
            try{
                obj = element.getAsJsonObject();
                JsonElement elementA = obj.get("variableName");
                JsonElement elementB = obj.get("varialeName");

                int convertedElementA = elementA.getAsInt();
                int convertedelementB  = elementB.getAsInt();

            }catch (Exception ee){
                LOG.info("...");
            }

        }
    }
}
@覆盖
公共void onResponse(调用、响应){
if(response.body()!=null){
JsonParser=新的JsonParser();
JsonElement元素=parser.parse(response.body());
如果(!element.isJsonNull()){
JsonObject对象;
试一试{
obj=element.getAsJsonObject();
JsonElement elementA=obj.get(“variableName”);
JsonElement elementB=obj.get(“变量名”);
int convertedElementA=elementA.getAsInt();
int convertedelementB=elementB.getAsInt();
}捕获(异常ee){
LOG.info(“…”);
}
}
}
}
您希望得到什么答复?[{“个人资料”:{“id”:“d712923e-62a1-11e5-9d70-feff819cdc9f”,“电子邮件”:trevor@ribot.co.uk《阿凡达》:“用像素和魔法打造优雅的多设备体验,同时享受工匠咖啡和铅笔剃须烟雾。人们还可以发现他正在谈论迪斯尼乐园(再次),疯狂地玩电子游戏,或在某物上画脸。”,“isActive”:真,“name”:{“first”:“Trevor”,“last”:“May”}}]
Log.i("xxxxxxggggxxxxxxxxxxx",""+rs.size());
@Headers("Content-Type: application/json")
@GET("Allusers/{iD}")
Call<String> doesUserExists(@Path("iD") String iD);
@Override
public void onResponse(Call<String> call, Response<String> response) {
    if(response.body() != null){
        JsonParser parser = new JsonParser();
        JsonElement element = parser.parse(response.body());
        if(!element.isJsonNull()){
            JsonObject obj;
            try{
                obj = element.getAsJsonObject();
                JsonElement elementA = obj.get("variableName");
                JsonElement elementB = obj.get("varialeName");

                int convertedElementA = elementA.getAsInt();
                int convertedelementB  = elementB.getAsInt();

            }catch (Exception ee){
                LOG.info("...");
            }

        }
    }
}