/**
* list转成json
* @param list
* @return
*/
public static String listToJson(List<?> list) {
// StringBuilder json = new StringBuilder();
// String jsonStr = "{\"data\":\"";
String tempStr = null;
try {
JSONArray json;
json = JSONArray.fromObject(list);
// String tempStr = null;
tempStr = json.toString().replace('{', '[');
tempStr = tempStr.replace('}', ']');
tempStr = tempStr.replaceAll("\\s*['\"]?\\w+['\"]?\\:\\s*", "");
// jsonStr += tempStr;
// jsonStr += "\",\"success\":true}";
} catch (Exception ex) {
ex.printStackTrace();
}
return tempStr;
}List 转成 Json
最新推荐文章于 2022-10-18 09:41:23 发布
1393

被折叠的 条评论
为什么被折叠?



