一个注意的地方:要选对jar包
Map map = new HashMap();map.put("success", "true");map.put("photoList", photoList);map.put("currentUser", "zhang");//net.sf.json.JSONObject 将Map转换为JSON方法JSONObject json = JSONObject.fromObject(map);//org.json.JSONObject 将Map转换为JSON方法JSONObject json =new JSONObject(map);