Convert JSON Array to Java ArrayList
import com.google.gson.Gson;
import org.json.simple.JSONValue;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
public static List<Map<String, Object>> parseJSONStringToArraList(String jSonListString) {
List<Map<String, Object>> parsedList =new ArrayList<Map<String, Object>>();
try {
JsonParser parser = new JsonParser();
JsonElement element = parser.parse(insuranceListString);
JsonArray jasonArray = element.getAsJsonArray();
Gson GSON = new Gson();
List<Map<String, Object>> parsedList = GSON.fromJson(jasonArray,
List.class);
} catch (Exception e) {
e.printStackTrace();
}
parsedList;
}
Post a Comment
0 Comments