您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Java二维数组转json的实现方法

2024/5/11 15:02:34发布25次查看
这篇文章主要介绍了java实现二维数组转json的方法,涉及java数组遍历及json格式数据构造相关操作技巧,需要的朋友可以参考下
本文实例讲述了java实现二维数组转json的方法。分享给大家供大家参考,具体如下:
package tsets; public class erweitojson { public static void main(string[] args) { string[][] bloglist = { {"2008/07/07", "netbeans new and cool", "tim boudreau"}, {"2008/07/07", "netbeans mobility", "ada li"}, {"2008/07/07", "creating web 2.0 rich internet applications", "michael li"}, {"2008/07/08", "ajax and jsf", "ada li"}, {"2008/07/09", "ruby on rails in the enterprise", "liang ye"}, {"2008/07/09", "beans binding and the swing application framework", "joey shen"} }; stringbuffer sb = new stringbuffer(); boolean first = true; sb.append("["); for (int i = 0; i < bloglist.length; i++) { string[] blogitem = bloglist[i]; if (!first) { sb.append(","); } sb.append("{"); sb.append("postdate: '" + blogitem[0] + "', "); sb.append("title: '" + blogitem[1] + "', "); sb.append("author: '" + blogitem[2] + "' "); sb.append("}"); first = false; } sb.append("]"); system.out.println(sb.tostring()); } }
运行结果:
复制代码 代码如下:
[{postdate: '2008/07/07', title: 'netbeans new and cool', author: 'tim boudreau' },{postdate: '2008/07/07', title: 'netbeans mobility', author: 'ada li' },{postdate: '2008/07/07', title: 'creating web 2.0 rich internet applications', author: 'michael li' },{postdate: '2008/07/08', title: 'ajax and jsf', author: 'ada li' },{postdate: '2008/07/09', title: 'ruby on rails in the enterprise', author: 'liang ye' },{postdate: '2008/07/09', title: 'beans binding and the swing application framework', author: 'joey shen' }]
以上就是java二维数组转json的实现方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product