如何将数据库中的数据取出来后用json包装

2025-01-07 01:16:06
推荐回答(3个)
回答1:

/**
*将List转化为json字符串
*@paramlistList
*@returnStringjson格式的字符串
*/
publicstatic String getString4List(List list)
{
JSONArray jsonArray = JSONArray.fromObject(list);
return jsonArray.toString();
}

回答2:

JSONObject json = new JSONObject();
json.element("bankPro", ParameterUtils.idByName("1", min.getBankPro()));
json.element("min", min);
json.element("ips", ips);
System.out.println(json);

回答3:

Struts2Utils.renderJson(brandBusinessDepartmentService.getAvailableBrandBusinessDepartmentByName(name));