java list转json

说明:将[a:12,b:12,c:34]转成["a":"12","b":"12","c":"34"]

 

 

 

List<dboViewGcLawenforcecert> dboviewgclawenforcecertlist = null;
dboviewgclawenforcecertlist = queryEntities(dboViewGcLawenforcecert.class, null, where, (intPage - 1) * number, number,
params);
List<Object> count = basedao.queryBySQL("select count(*) from " + dboViewGcLawenforcecert.TABLE_NAME, null,
null);

//list放到map里

Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("total", count == null ? 0 : count.get(0));
jsonMap.put("rows", dboviewgclawenforcecertlist);

//转换
JSONObject obj = JSONObject.fromObject(jsonMap);

return obj.toString();

posted @ 2016-04-27 11:16  安静的程序媛  阅读(518)  评论(0编辑  收藏  举报