How to convert a JSON which is a combination of String and an Array,please suggest how to do that with a code,suppose we have the following JSON
{"status":"true","results":[{"name":"Sudini "},{"name":"Bimal"}]}
If you do this in GSON:
public class Something{
@SerializedName("status")
private boolean status;
@SerializedName("results")
private List<Result> results;
// accessor and mutator
}
public class Result{
@SerializedName("name")
private String name;
// accessor and mutator
}
public class App {
public static void main(String[] args) {
Gson gson = new Gson();
String jsonString = // your json string
Something obj = (Something) gson.fromJson(jsonString, Something.class);
System.out.println(obj.getResults().get(1).getName());
}
}