fastjson list转JSONArray
fastjson
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
项目地址:https://gitcode.com/gh_mirrors/fastj/fastjson

·
需求:项目中用到了ztree,数据必须是数据对象,目前后台查出了一个List<Map<String,Object>>对象,直接传给前台的ztree是不可以的。
解决:引入fastjson包(比使用json-lib.jar好,因为这个只需要引入一个jar,而json-lib需引入五六个jar包)
controller层
public String treeData(Model model){
model.addAttribute("mapList",JSONArray.parseArray(JSON.toJSONString(treeMapList)));
return "tree";
}
jsp:
$.fn.zTree.init($("#ztree"),setting,${mapList}).expandAll(true);
下面的链接整理的更好:
http://www.cnblogs.com/goody9807/p/4244862.html




FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:27 天前 )
c942c834 - 2 年前
5bc4709b - 2 年前
更多推荐
所有评论(0)