JSON String to Android class object conversion using GSON

JSON Array conversion

Gson gson = new Gson();
List globalDataListModelArrayList = new ArrayList();
globalDataListModelArrayList = Arrays.asList(gson.fromJson(matterEditModels.get(position).getGlobalDataList(), GlobalDataListModel[].class));

JSON Object conversion

Gson gson = new Gson();
GlobalDataListModel globalDataListModelArrayList = new GlobalDataListModel();
globalDataListModelArrayList = gson.fromJson(matterEditModels.get(position).getGlobalDataList(), GlobalDataListModel[].class);


Leave a Reply

Your email address will not be published. Required fields are marked *