Перечислить <Map <String, Object >> в org.json.JSONObject?

List> list = new ArrayList>();
Map map = new HashMap();

map.put("abc", "123456");
map.put("def", "hmm");
list.add(map);
// it's wrong JSONObject json = new JSONObject(list);
// if u use list to add data u must be use JSONArray

JSONArray json = JSONArray.fromObject(list);
try {
    System.err.println(json.toString(2));
} catch (JSONException e) {
    e.printStackTrace();
}

json-encode

java

json

javabeans

map

2022-07-09T14:45:25+00:00