这篇文章将为大家详细讲解有关利用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()); } }