list,Object数据转换成json数据

//list转换成json数组
public static JSONArray list2CtsJSON(List<? extends Object> list) {

        JSONArray jsonArray = new JSONArray();
       
        if (list != null && !list.isEmpty()) {
                       
            for (Object bean : list) {
               
                jsonArray.add(bean);
            }
        }
       
        return jsonArray;
    }

//Object转换成数据
private static JSONObject bean2JSON(Object bean,String properties)

    JSONObject row= new JSONObject();
     if (bean!= null && !bean.isEmpty())
    {
          row.element(properties, bean);
     }
  

}

你可能感兴趣的:(object)