代码是:如何将地图添加到列表中
public List<Map<Object, Object>> getReportees(String idOfEmp) throws Exception {
JSONArray jsonarr_s = (JSONArray) jobj.get("list");
Map<Object, Object> map = new HashMap<Object, Object>();
if (jsonarr_s.size() > 0) {
// Get data for List array
for (int i = 0; i < jsonarr_s.size(); i++) {
JSONObject jsonobj_1 = (JSONObject) jsonarr_s.get(i);
JSONObject jive = (JSONObject) jsonobj_1.get("jive");
Object names = jsonobj_1.get("displayName");
Object userid = jive.get("username");
map.put(names, userid); //return the map with the key value pairs
map = new HashMap<Object, Object>();
String UserId = userid.toString();
String output1 = resp1.getEntity(String.class);
JSONObject jobjs = (JSONObject) new JSONParser().parse(output1);
// Store the JSON object in JSON array as objects (For level 1 array element i.e
// issues)
JSONArray jsonarr_new = (JSONArray) jobjs.get("issues");
int numofjiras = jsonarr_new.size(); //this jira count must be mapped to the name and id
map.put("count", numofjiras);
}
return map;
} else {
map.put("errorcheck", msg);
}
return map;
}
}
I want the output like:
Name id count
AJ 235457 2
Geet 637571 0
实际上我在键值对中获取名称和 id。然后我试图将每个 id 传递给一个 api,它会给我计数。那么我怎样才能返回所有的文件,即名称、id 和计数。所以我在这里尝试为这个用户 ID 和名称进行映射,这是计数。我们如何才能实现它。请帮助。谢谢。
慕工程0101907
千巷猫影
慕姐8265434
随时随地看视频慕课网APP
相关分类