0
我写了这个代码:的java:JSON解析器问题相同字符串
private ArrayList<HashMap<String, HashMap<Integer, String>>> listContent2 = new ArrayList<HashMap<String, HashMap<Integer, String>>>();
public ArrayList<HashMap<String, HashMap<Integer, String>>> content() {
JSONObject json = JSONfunctions.getJSONfromURL("http://...");
try {
JSONArray hotspots = json.getJSONArray("hotspots");
HashMap<String, HashMap<Integer, String>> mapContentHotspot = new HashMap<String, HashMap<Integer, String>>();
for (int i = 0; i < hotspots.length(); i++) {
JSONObject e = hotspots.getJSONObject(i);
JSONArray actions = new JSONArray(e.getString("actions"));
for (int j = 0; j < actions.length(); j++) {
JSONObject e2 = actions.getJSONObject(j);
HashMap<Integer, String> mapContent = new HashMap<Integer, String>();
switch (e2.getInt("activityType")) {
case 27:
mapContent.put(e2.getInt("activityType"), e2.getString("uri"));
case 2:
mapContent.put(e2.getInt("activityType"), e2.getString("uri"));
case 1:
mapContent.put(e2.getInt("activityType"), e2.getString("uri"));
//default:
//break;
}
mapContentHotspot.put(e.getString("id"), mapContent);
}
listContent2.add(mapContentHotspot);
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
return listContent2;
}
借此JSON数组的内容: http://pastebin.com/bXfwcQ2U 问题出在“行动”的部分。我尝试采取3“uri”,但我只采取最后一个(与“activityType”:“1”)。我的Java代码在哪里错了? 谢谢!
通常,是的。但在这种情况下,它不会有所作为,因为所有情况都是相同的,并且是幂等的。 – Thilo 2011-08-17 13:12:17
正是它所说的Thilo!与“休息”它不起作用! – John 2011-08-17 13:22:00