If you are using org.json.simple.JSONArray
(https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1)
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("abc", "123456");
map.put("def", "hmm");
list.add(map);
JSONArray jsonArray = new JSONArray();
jsonArray.addAll(listOfMaps);
You have a map nested inside a list. you are trying to call the Map without ever iterating through the list first. JSON sometimes feels like magic but in fact it is not.
I'll post some code in a moment.
It would be more consistent with JSON to make a Map of Maps instead of a List of Maps.
JSONObject json = new JSONObject(list);
Iterator<?> it = json.keys();
while (keyed.hasNext()) {
String x = (String) it.next();
JSONObject jo2 = new JSONObject(jo.optString(x));
}