Home Not getting correct json response as expected actual response
Reply: 0

Not getting correct json response as expected actual response

user3388
1#
user3388 Published in April 22, 2018, 6:49 am

This is my code the actual response and expected response in entirely different. can anyone trace out my mistake, thanks in advance.

Main activity

        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;
        }

    }

Name

public class Name {

    @SerializedName("first")
    @Expose
    private String first;
    @SerializedName("last")
    @Expose
    private String last;

    public String getFirst() {
        return first;
    }

    public void setFirst(String first) {
        this.first = first;
    }

    public String getLast() {
        return last;
    }

    public void setLast(String last) {
        this.last = last;
    }

}

ApiCLIENT

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

}

Its actual response is

[{"profile":{"id":"d712923e-62a1-11e5-9d70-feff819cdc9f","email":"trevor@ribot.co.uk","avatar":"https://s3-eu-west-1.amazonaws.com/api.ribot.io/trevor_big.png","dateOfBirth":"1990-01-01T00:00:00.000Z","hexColor":"#B60042","bio":"Trevor crafts elegant multi-device experiences with pixels and magic while tanked up on artisan coffee and Col-Erase pencil shaving fumes. He can also be found going on about Disneyland (again), playing video games terribly, or drawing a face on something.","isActive":true,"name":{"first":"Trevor","last":"May"}}}]

This is the response I receive info.androidhive.retrofit.model.UserModel@9c6c34c

This is my code the actual response and expected response in entirely different. can anyone trace out my mistake, thanks in advance.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306353 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO