Ok. So, you want to use GSON.
First, Go to http://www.jsonschema2pojo.org/ and create relavent one POJO Class.
Below would be the Model Class :
Example.java
public class Example {
@SerializedName("0")
@Expose
private Integer _0;
@SerializedName("1")
@Expose
private String _1;
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("name")
@Expose
private String name;
/**
*
* @return
* The _0
*/
public Integer get0() {
return _0;
}
/**
*
* @param _0
* The 0
*/
public void set0(Integer _0) {
this._0 = _0;
}
/**
*
* @return
* The _1
*/
public String get1() {
return _1;
}
/**
*
* @param _1
* The 1
*/
public void set1(String _1) {
this._1 = _1;
}
/**
*
* @return
* The id
*/
public Integer getId() {
return id;
}
/**
*
* @param id
* The id
*/
public void setId(Integer id) {
this.id = id;
}
/**
*
* @return
* The name
*/
public String getName() {
return name;
}
/**
*
* @param name
* The name
*/
public void setName(String name) {
this.name = name;
}
}
Now, you do not need to create second Model class if there are JSONArray in response. you can try out below ways to get your ArrayList<Example>
.
Type collectionType = new TypeToken<ArrayList<Example>>() {}.getType();
ArrayList<Example> tripList = tripListGson.fromJson(YOUR JSON ARRAY STRING HERE, collectionType);
I hope it would help you out.