网上很多list转JsonArray,在实际中用不了,。 private List<WmCheckListBean> checkListBean=new ArrayList<>();
JSONArray arry= new JSONArray();
for ( int a= 0;a< checkListBean.size();a++){
JSONObject jsonObject= new JSONObject();
try {
jsonObject.put( "id", checkListBean.get(a).getCheckId());
jsonObject.put( "name", checkListBean.get(a).getCheckName());
jsonObject.put( "parentId", checkListBean.get(a).getParentId());
jsonObject.put( "type", checkListBean.get(a).getType()); }
catch (JSONException e) {
e.printStackTrace();
}
arry.put(jsonObject);}