通过JSONObject循环会产生null元素。我的jsonString是:
{"user1":[{"43":1558631338651},{"40":1558631347443}],"user2":[{"367":1558631214488},{"365":1558631222849},{"362":1558631231942}]}
@SuppressWarnings("unchecked")
public void loadMapFromJsonString(String jsonString) {
try {
JSONObject json = (JSONObject) new JSONParser().parse(jsonString);
//json converts to an object... and the for loop works, but
//list is always null
for (int i = 0; i < json.size(); i++) {
List<HashMap<String, Long>> list = (List<HashMap<String, Long>>) json.get(i);
System.out.println(list); //always null..??
}
}
catch (Exception e) {
System.out.println(e);
//log this
}
}
for循环中的列表始终为空。为什么会这样?