1

How to retrieve this ? I tried creating 2 model class one for the "sys" and the other one is for the child of "sys" but it did not work:

class Sys:

public class Sys {
private ArrayList<SysInfo> sys = new ArrayList<>();

public ArrayList<SysInfo> getSys() {
    return sys;
}

public void setSys(ArrayList<SysInfo> sys) {
    this.sys = sys;
}

class SysInfo

public class SysInfo {
private String country;

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

And this is the JSON enter image description here

1 Answer 1

1

To get sys object user

import com.google.gson.annotations.SerializedName;

public class SysParent {
    @SerializedName("sys")

    private Sys sysObj;

    public Sys getSysObj() {
        return sysObj;
    }

    public void setSysObj(Sys sysObj) {
        this.sysObj = sysObj;
    }
}

and to get values in sys use following class.

import com.google.gson.annotations.SerializedName;

public class Sys {

    @SerializedName("country") private String country;

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

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.