map转json pojo转map

=============json==============
后台
Map<String,String> htmlMap = new HashMap<String,String>();
org.json.JSONObject json = new org.json.JSONObject.JSONObject(htmlMap);
response.setContentType("text/plain;charset=UTF-8");
response.setDateHeader("Expires", 0);
response.addHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write(json.toString());

前台
result = eval('(' + result + ')');
var itemHtml = result.itemHtml;



// POJO转成map 
Map<String, String> paramMap = org.apache.commons.beanutils.PropertyUtils.describe(dto);
JSONObject json = new JSONObject(paramMap);
json.remove("class");

相关推荐