{
"status": "success",
"msg": "User successfully logged in",
"userdata": {
"0": "2",
"1": "Sofia Raza",
"2": "",
"3": "M",
"4": "9995890332",
"5": "5158",
"6": "stud_image_files/59dc990b71106.jpg",
"7": "1",
"8": "12",
"9": "Sofia Manzill",
"10": "0",
"11": "0",
"12": "2017-08-15 11:33:30",
"13": "Raza Hassan",
"14": "21673",
"15": "Hasna Raza",
"16": "673636",
"17": "Sreekaryam",
"18": "2003-12-17",
"19": "9",
"20": "21673",
"21": "8-A",
"22": "1",
"student_id": "2",
"first_name": "Sofia Raza",
"last_name": "",
"gender": "M",
"student_phoneno": "9995890332",
"student_barcode": "5158",
"student_photo": "stud_image_files/59dc990b71106.jpg",
"class_id": "1",
"rollnumber": "12",
"house": "Sofia Manzill",
"is_deleted": "0",
"is_active": "0",
"last_updated": "2017-08-15 11:33:30",
"father_name": "Raza Hassan",
"username": "21673",
"mother_name": "Hasna Raza",
"pincode": "673636",
"post": "Sreekaryam",
"dob": "2003-12-17",
"updated_by": "9",
"admission_number": "21673",
"class_name": "8-A"
}
}
在此json中,如何获取“ userdata”字段到模型类?
答案 0 :(得分:0)
尝试这种方式::
public class Response {
@SerializedName("status")
@Expose
private String status;
@SerializedName("msg")
@Expose
private String msg;
@SerializedName("userdata")
@Expose
private Userdata userdata;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Userdata getUserdata() {
return userdata;
}
public void setUserdata(Userdata userdata) {
this.userdata = userdata;
}
public class Userdata {
@SerializedName("0")
@Expose
private String _0;
@SerializedName("1")
@Expose
private String _1;
@SerializedName("2")
@Expose
private String _2;
@SerializedName("3")
@Expose
private String _3;
@SerializedName("4")
@Expose
private String _4;
@SerializedName("5")
@Expose
private String _5;
@SerializedName("6")
@Expose
private String _6;
@SerializedName("7")
@Expose
private String _7;
@SerializedName("8")
@Expose
private String _8;
@SerializedName("9")
@Expose
private String _9;
@SerializedName("10")
@Expose
private String _10;
@SerializedName("11")
@Expose
private String _11;
@SerializedName("12")
@Expose
private String _12;
@SerializedName("13")
@Expose
private String _13;
@SerializedName("14")
@Expose
private String _14;
@SerializedName("15")
@Expose
private String _15;
@SerializedName("16")
@Expose
private String _16;
@SerializedName("17")
@Expose
private String _17;
@SerializedName("18")
@Expose
private String _18;
@SerializedName("19")
@Expose
private String _19;
@SerializedName("20")
@Expose
private String _20;
@SerializedName("21")
@Expose
private String _21;
@SerializedName("22")
@Expose
private String _22;
@SerializedName("student_id")
@Expose
private String studentId;
@SerializedName("first_name")
@Expose
private String firstName;
@SerializedName("last_name")
@Expose
private String lastName;
@SerializedName("gender")
@Expose
private String gender;
@SerializedName("student_phoneno")
@Expose
private String studentPhoneno;
@SerializedName("student_barcode")
@Expose
private String studentBarcode;
@SerializedName("student_photo")
@Expose
private String studentPhoto;
@SerializedName("class_id")
@Expose
private String classId;
@SerializedName("rollnumber")
@Expose
private String rollnumber;
@SerializedName("house")
@Expose
private String house;
@SerializedName("is_deleted")
@Expose
private String isDeleted;
@SerializedName("is_active")
@Expose
private String isActive;
@SerializedName("last_updated")
@Expose
private String lastUpdated;
@SerializedName("father_name")
@Expose
private String fatherName;
@SerializedName("username")
@Expose
private String username;
@SerializedName("mother_name")
@Expose
private String motherName;
@SerializedName("pincode")
@Expose
private String pincode;
@SerializedName("post")
@Expose
private String post;
@SerializedName("dob")
@Expose
private String dob;
@SerializedName("updated_by")
@Expose
private String updatedBy;
@SerializedName("admission_number")
@Expose
private String admissionNumber;
@SerializedName("class_name")
@Expose
private String className;
public String get0() {
return _0;
}
public void set0(String _0) {
this._0 = _0;
}
public String get1() {
return _1;
}
public void set1(String _1) {
this._1 = _1;
}
public String get2() {
return _2;
}
public void set2(String _2) {
this._2 = _2;
}
public String get3() {
return _3;
}
public void set3(String _3) {
this._3 = _3;
}
public String get4() {
return _4;
}
public void set4(String _4) {
this._4 = _4;
}
public String get5() {
return _5;
}
public void set5(String _5) {
this._5 = _5;
}
public String get6() {
return _6;
}
public void set6(String _6) {
this._6 = _6;
}
public String get7() {
return _7;
}
public void set7(String _7) {
this._7 = _7;
}
public String get8() {
return _8;
}
public void set8(String _8) {
this._8 = _8;
}
public String get9() {
return _9;
}
public void set9(String _9) {
this._9 = _9;
}
public String get10() {
return _10;
}
public void set10(String _10) {
this._10 = _10;
}
public String get11() {
return _11;
}
public void set11(String _11) {
this._11 = _11;
}
public String get12() {
return _12;
}
public void set12(String _12) {
this._12 = _12;
}
public String get13() {
return _13;
}
public void set13(String _13) {
this._13 = _13;
}
public String get14() {
return _14;
}
public void set14(String _14) {
this._14 = _14;
}
public String get15() {
return _15;
}
public void set15(String _15) {
this._15 = _15;
}
public String get16() {
return _16;
}
public void set16(String _16) {
this._16 = _16;
}
public String get17() {
return _17;
}
public void set17(String _17) {
this._17 = _17;
}
public String get18() {
return _18;
}
public void set18(String _18) {
this._18 = _18;
}
public String get19() {
return _19;
}
public void set19(String _19) {
this._19 = _19;
}
public String get20() {
return _20;
}
public void set20(String _20) {
this._20 = _20;
}
public String get21() {
return _21;
}
public void set21(String _21) {
this._21 = _21;
}
public String get22() {
return _22;
}
public void set22(String _22) {
this._22 = _22;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getStudentPhoneno() {
return studentPhoneno;
}
public void setStudentPhoneno(String studentPhoneno) {
this.studentPhoneno = studentPhoneno;
}
public String getStudentBarcode() {
return studentBarcode;
}
public void setStudentBarcode(String studentBarcode) {
this.studentBarcode = studentBarcode;
}
public String getStudentPhoto() {
return studentPhoto;
}
public void setStudentPhoto(String studentPhoto) {
this.studentPhoto = studentPhoto;
}
public String getClassId() {
return classId;
}
public void setClassId(String classId) {
this.classId = classId;
}
public String getRollnumber() {
return rollnumber;
}
public void setRollnumber(String rollnumber) {
this.rollnumber = rollnumber;
}
public String getHouse() {
return house;
}
public void setHouse(String house) {
this.house = house;
}
public String getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(String isDeleted) {
this.isDeleted = isDeleted;
}
public String getIsActive() {
return isActive;
}
public void setIsActive(String isActive) {
this.isActive = isActive;
}
public String getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(String lastUpdated) {
this.lastUpdated = lastUpdated;
}
public String getFatherName() {
return fatherName;
}
public void setFatherName(String fatherName) {
this.fatherName = fatherName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getMotherName() {
return motherName;
}
public void setMotherName(String motherName) {
this.motherName = motherName;
}
public String getPincode() {
return pincode;
}
public void setPincode(String pincode) {
this.pincode = pincode;
}
public String getPost() {
return post;
}
public void setPost(String post) {
this.post = post;
}
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public String getAdmissionNumber() {
return admissionNumber;
}
public void setAdmissionNumber(String admissionNumber) {
this.admissionNumber = admissionNumber;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
}
}