码迷,mamicode.com
首页 > 编程语言 > 详细

java list转json

时间:2016-04-27 12:52:16      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:

说明:将[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();

java list转json

标签:

原文地址:http://www.cnblogs.com/latter/p/5438172.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!