HashMap<String, String> map = new HashMap<String, String>(); String jsonStr="[{\"key\":\"1\"},{\"key1\":\"2\"}]"; JSONArray jsonArr=JSONArray.fromObject(jsonStr); for(int i=0;i<jsonArr.size();i++){ JSONObject obj = JSONObject.fromObject(jsonArr.get(i)); Iterator it = obj.keys(); while (it.hasNext()){ String key = String.valueOf(it.next()); String value = (String) obj.get(key); map.put(key, value); } } System.out.println(map); 追问 大神帮忙看一下我的代码其中得到的str是[{"id":3,"driver_id":1,"position":"客厅"},{"id":9,"driver_id":1,"position":"厨房"}]但是在前端得到的是{"id":"9","position":"厨房","driver_id":"1"},只有一条数据,怎么样得到全部数据??? 追答 因为KEY一样,第二次又被重新赋值了