There is a cycle in the hierarchy! json转换异常
在网上看到了很多方法 使用 jsonconfig 过滤掉属性 还是不行
public void plist() {
// TODO Auto-generated method stub
List<Province> plist=pcd.plist();
JsonConfig config=new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
// TODO Auto-generated method stub
if(arg1.equals("cities")||arg1.equals("userinfos")){
return true;
}
return false;
}
});
JSONArray json=JSONArray.fromObject(plist,config);
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("utf-8");
try {
response.getWriter().write(json.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}