JsonConfig config = new JsonConfig(); config.setIgnoreDefaultExcludes(false); config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); config.setExcludes(new String[]{//只要设置这个数组,指定过滤哪些字段。 // "l2Interfaces", // "OSInstalled", "ipInterfaces", "OSRunning", "fileSystems", "balanceMan", "endStation" });
JSONArray jsonArray = JSONArray.fromObject(str); for (int i = 0; i < jsonArray.size(); i++) { Object o = jsonArray.get(i);
//如果不需要过滤,方法可用fromObject(o)
JSONObject jsonObject = JSONObject.fromObject(o,config);
tt = (TT)JSONObject.toBean(jsonObject, TT.class);
System.out.println(tt);
}