当前位置:首页 > 开发 > 编程语言 > Json > 正文

二维数组转换成JSON

发表于: 2014-04-27   作者:tangqi609567707   来源:转载   浏览:
摘要: 原文出处:http://blog.csdn.net/springsen/article/details/7833596 public class Demo {     public static void main(String[] args) {        String[][] blogL

原文出处:http://blog.csdn.net/springsen/article/details/7833596

public class Demo {

    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());
    }
}

二维数组转换成JSON

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号