list JSONArray 相互转换

public net.sf.json.JSONArray removeChaoXingInfo(JSONArray array) {
List<JSONObject> list = new ArrayList<>();
for (int i = 0; i < array.size(); i++) {
list.add((JSONObject) array.get(i));
}
Iterator<JSONObject> iterator = list.iterator();
while (iterator.hasNext()) {
JSONObject json = iterator.next();
if ("1385".equals(json.getString("schoolid"))) {
iterator.remove();
} else if ("0".equals(json.getString("schoolid"))) {
iterator.remove();
} else if ("1467".equals(json.getString("schoolid"))) {
iterator.remove();
} else if ("11889".equals(json.getString("schoolid"))) {
iterator.remove();
}
}
net.sf.json.JSONArray json = net.sf.json.JSONArray.fromObject(list);
return json;

}

net.sf.json. 这个包下可以直接将list 转为JSONArray 

猜你喜欢

转载自blog.csdn.net/qq_33580178/article/details/80669384
今日推荐