package com.admin.model; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class Sys_Function extends MyDB<Sys_Function>{ /** * */ private static final long serialVersionUID = 1L; public static final Sys_Function dao = new Sys_Function(); public Sys_Function() { tableName = "sys_function"; } private List<Sys_Function> children = new ArrayList<Sys_Function>(); public List<Sys_Function> getChildren() { return children; } public void setChildren(List<Sys_Function> children) { this.children = children; } protected Map<String, Object> getAttrs() { Map<String, Object> attrs= super.getAttrs(); attrs.put("children", this.getChildren()); return attrs; } }
重写getAttrs 都不管用,因为getAttrs()方法最新调用,而获取值后的自定义属性也无法put值,感觉还是非常鸡肋,只能获取数据库字段值
项目:JFinal
如果是用的 jfinal 自带的 json 功能,那么不会调用这个 getter 方法,使用 fastjson 实现即可:
me.setJsonFactory(new FastJsonFactory());