0

My response is like this..

{
    "IsSuccess": true,
    "ResponseObject": ["one", "two", "three", "four", "five"]
}}

i tried to do by creating POJO. Kindly help me with the solution.

6
  • post your pojo also Commented Dec 6, 2017 at 6:24
  • 4
    Before asking any question, Please let us know your effort, till now what you had done ? Commented Dec 6, 2017 at 6:25
  • 1
    Possible duplicate of Parse JSON array response using Retrofit & Gson Commented Dec 6, 2017 at 6:31
  • @nihal_softy thanks for the advice.I am new to stackoverflow. When i ask a about next i will definitely follow your advice. Anyhow i got the solution. Thanks again Commented Dec 6, 2017 at 6:45
  • Thanks you @Sudheesh,ADM Commented Dec 6, 2017 at 6:46

1 Answer 1

4

Your POJO class should be like this.

public class TempParams {
    /**
     * IsSuccess : true
     * ResponseObject : ["one","two","three","four","five"]
     */

    private boolean IsSuccess;
    private List<String> ResponseObject;

    public boolean isIsSuccess() {
        return IsSuccess;
    }

    public void setIsSuccess(boolean IsSuccess) {
        this.IsSuccess = IsSuccess;
    }

    public List<String> getResponseObject() {
        return ResponseObject;
    }

    public void setResponseObject(List<String> ResponseObject) {
        this.ResponseObject = ResponseObject;
    }

}

After successfully getting response object you have to convert it like this.

Gson gson = new Gson();
TempParams model = gson.fromJson(mObject.toString(), TempParams.class);

Now you can get value from POJO class.

Sign up to request clarification or add additional context in comments.

2 Comments

answering duplicate questions you encourage people to be lazy, and not to use search before asking.
Having below 10 reputation we figure out that he is newbie not intelligent enough like you brother! now on-wards he will make sure how to ask question on community.Apart from this you can find comments below the question.which states the same thing rather than giving quick solution to their problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.