You can make POJO classes to pass in Gson for JSON parsing
Gson gson = new Gson();
Detail details = gson.fromJson(response, Detail .class);
com.example.Data.java
package com.example;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Data {
@SerializedName("Details")
@Expose
private List<Detail> details = null;
@SerializedName("Other")
@Expose
private List<Other> other = null;
public List<Detail> getDetails() {
return details;
}
public void setDetails(List<Detail> details) {
this.details = details;
}
public List<Other> getOther() {
return other;
}
public void setOther(List<Other> other) {
this.other = other;
}
}
com.example.Detail.java
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Detail {
@SerializedName("Code")
@Expose
private String code;
@SerializedName("Name")
@Expose
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
com.example.Example.java
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Example {
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("Data")
@Expose
private Data data;
@SerializedName("message")
@Expose
private String message;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
com.example.Other.java
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Other {
@SerializedName("age")
@Expose
private String age;
@SerializedName("gender")
@Expose
private String gender;
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
}