Json转换成字符串,There is a cycle in the hierarchy解决办法

来源:互联网 发布:淘宝购物数据流程图 编辑:程序博客网 时间:2024/04/30 06:51


1、原因由于对象内部相互引用出现死循环,而导致的错误;解决办法,排除掉相关的可以导致循环引用的对象。

      如下:

     JsonConfig jsonConfig = new JsonConfig();jsonConfig.setJsonPropertyFilter(new PropertyFilter() {@Overridepublic boolean apply(Object source, String name, Object value) {Set<String>  propertyNameList = new HashSet<String>();propertyNameList.add("itemQueryServiceClient");propertyNameList.add("uicExtraReadServiceClient");propertyNameList.add("shopReadService");propertyNameList.add("readServices");propertyNameList.add("bmQuali");if (propertyNameList.contains(name)) {return true;}return false;}});JSONObject jsonObject = JSONObject.fromObject(super.getPage(),jsonConfig);

 

0 0
原创粉丝点击