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.

Vivek Barai
  • 1,338
  • 13
  • 26
Bakyaraj
  • 35
  • 5

1 Answers1

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.

Kuls
  • 2,047
  • 21
  • 39
Radhey
  • 2,139
  • 2
  • 24
  • 42
  • 1
    answering duplicate questions you encourage people to be lazy, and not to use search before asking. – Vladyslav Matviienko Dec 06 '17 at 07:12
  • 1
    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. – Radhey Dec 06 '17 at 07:17