从表中读取一组数据,需生成如下的json数据
{"list":[{"name":"张三","性别":"男"},{"name":"李四","性别":"女"},{"name":"赵六","性别":"男"}]}
请问使用org.json程序要如何写?

解决方案 »

  1.   

    String aa = "{id:0,item: [{item:[{item:[],text:\"资源目录管理\",id:2},{item:[],text:\"人员管理\",id:3},{item:[],text:\"授权管理\",id:4}],text:\"权限管理\",id:1}] }";参照的改下吧{id:0,item:[{item:[{item:[],text:\"uuuu\",id:0493f228-fd49-4371-8fd4-49441eeeffc0}],text:\"角色管理\",id:roleroot}]}";
      

  2.   

    楼上说的不对
    我自己搞定了:  JSONObject jsonObject = new JSONObject();
            JSONArray array = new JSONArray();        Map<String, String> stu1 = new HashMap<String, String>();
            stu1.put("name", "张三");
            stu1.put("性别", "男");        Map<String, String> stu2 = new HashMap<String, String>();
            mm.put("name", "李四");
            mm.put("性别", "女");        array.put(stu1);
            array.put(stu2);
            jsonObject.put("list", array);        System.out.println(jsonObject);