[JAVA] Convert Json to List <T> as it is

Convert JsonArray to List as it is. Use the Type of the reflect package

JSONArray jsonArray;
//Some value is entered in jsonArray
Gson gson = new Gson();
Type listType = new TypeToken<List<Dto>>() {}.getType();
List<Dto> dtoList = gson.fromJson(jsonArray.toString(), listType);

http://stackoverflow.com/questions/8371274/how-to-parse-json-array-in-android-with-gson

Recommended Posts