【发布时间】:2018-04-12 08:46:13
【问题描述】:
private void showResult(){
try {
JSONObject jsonObject = new JSONObject(mJsonString);
JSONArray jsonArray = jsonObject.getJSONArray(TAG_JSON);
for(int i=0;i<jsonArray.length();i++){
JSONObject item = jsonArray.getJSONObject(i);
String id = item.getString(TAG_ID);
HashMap<String,String> hashMap = new HashMap<>();
hashMap.put(TAG_ID, id);
String aa = hashMap.get("user_no");
mArrayList.add(hashMap);
}
}
}
我想将 Hashmap 中的数据转换为 ArrayList 或其他东西
我尝试了其他方法但不能
【问题讨论】:
-
您还尝试过什么其他方法?
-
创建一个复合对象,有两个变量:key 和 content。遍历您的地图,并为每个元素创建其键和值的实例,并将它们存储在您的列表中
-
您的代码似乎创建了一个
ArrayList<HashMap>。这不是你想要的吗? -
我想将 hashmap 中的数据写入 ArrayList 或其他东西