日期:2014-05-19  浏览次数:20657 次

There is a cycle in the hierarchy!
用json-lib将list对象转成json串时提示"There is a cycle in the hierarchy!"
按照网上的解决方法加JsonConfg配置

JsonConfig config = new JsonConfig();
config.setJavaPropertyFilter(new PropertyFilter(){
public boolean apply(Object arg0, String arg1, Object arg2) {
if(arg1.equals("children")||arg1.equals("parent")){
return true;
}else{
return false;
}
}

--但结果还是一样的
实体类Module中有:
private Module parent;
private Set<Module> children = new HashSet<Module>(0);


------解决方案--------------------
json-lib不能解决这种有嵌套关系的对象吧。