欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

map转json pojo转map

程序员文章站 2024-02-15 19:31:16
...

=============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");