list轉jsonarray時報錯There is a cycle in the hierarchy!

There is a cycle in the hierarchy!json

錯誤緣由:將對象轉換爲json串時的錯誤,可能緣由是存在級聯(及樹結構)或者對象間的互相調用。對象

解決方法:去掉級聯或者互相調用而致使干擾的對象,例如:io

    
      JsonConfig jsonConfig = new JsonConfig();  //創建配置文件
        jsonConfig.setIgnoreDefaultExcludes(false);  //設置默認忽略
        jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
        JSONArray ja=JSONArray.fromObject(list,jsonConfig);配置

相關文章
相關標籤/搜索