对jquery的ajax的一个封装(2)
来源:未知 责任编辑:责任编辑 发表时间:2015-03-01 01:36 点击:次
pw.write(JSONUtils.valueToString(json));
pw.flush();
}else{
//Employees not belong to any groupp
List employeeNotBelongToAnyGroup=loginService.getEmployeesNotBelongToAnyGroup();
logWrite.writeLog(LogPathUtil.getPath(), "Load employeeNotBelongToAnyGroup employeeNotBelongToAnyGroup.size():"+employeeNotBelongToAnyGroup.size(), "info");
JSONArray json = (JSONArray)JSONSerializer.toJSON(employeeNotBelongToAnyGroup);
response.setContentType("application/json;charset=gbk");
response.setCharacterEncoding("gbk");
PrintWriter pw = response.getWriter();
pw.write(JSONUtils.valueToString(json));
pw.flush();
}
return null;
}
public void setLoginService(LoginService loginService) {
this.loginService = loginService;
}
public static void main(String[] args) {
String testStr =
"{ \"employees\":[{\"user_id\": 841 , \"user_name\":\"EnidChen\"},{\"user_id\": \"1445\" , \"user_name\":\"JulieZhu\"},{\"user_id\": \"1447\" , \"user_name\":\"JasonMa\"}]}";
System.out.println(testStr);
Map json = (Map) JSONSerializer.toJSON(testStr);
List employees = (List) json.get("employees");
System.out.println(employees.size());
Map json2 = (Map) JSONSerializer.toJSON(employees.get(0));
System.out.println(json2.get("user_id"));
System.out.println(json2.get("user_name"));
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>