The json is not a valid one.I have edited your json.
{
"success":"true",
"contacts": {
"member" : [{"name" : "x","phone" : "43323284"}],
"invitation":[{"name":"y","phone":"78994993"}],
"invite":[{"name":"z","contact":"567896789"}]
}
}
Build your model classes like :
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Example {
@SerializedName("success")
@Expose
private String success;
@SerializedName("contacts")
@Expose
private Contacts contacts;
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
public Contacts getContacts() {
return contacts;
}
public void setContacts(Contacts contacts) {
this.contacts = contacts;
}
}
public class Contacts {
@SerializedName("member")
@Expose
private List<Member> member = new ArrayList<Member>();
@SerializedName("invitation")
@Expose
private List<Invitation> invitation = new ArrayList<Invitation>();
@SerializedName("invite")
@Expose
private List<Invite> invite = new ArrayList<Invite>();
public List<Member> getMember() {
return member;
}
public void setMember(List<Member> member) {
this.member = member;
}
public List<Invitation> getInvitation() {
return invitation;
}
public void setInvitation(List<Invitation> invitation) {
this.invitation = invitation;
}
public List<Invite> getInvite() {
return invite;
}
public void setInvite(List<Invite> invite) {
this.invite = invite;
}
}
public class Invitation {
@SerializedName("name")
@Expose
private String name;
@SerializedName("phone")
@Expose
private String phone;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
public class Invite {
@SerializedName("name")
@Expose
private String name;
@SerializedName("contact")
@Expose
private String contact;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
}
public class Member {
@SerializedName("name")
@Expose
private String name;
@SerializedName("phone")
@Expose
private String phone;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
To get the object from the json :
Example obj = new Gson().fromJson(jsonObject, Example.class);