现有JSON格式数据的字符串 菜单  我希望将这个格式的菜单转换成对象数组  在线等待解决
对象为public class FunMenu {

private String path;
private boolean disable;
private String name;
private List<FunMenu> child;}JSON 格式数据为:[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"首页","child":[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"作业","child":[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"费用支付","child":[{"path":"","disable":false,"name":"","child":[{"path":"warn_rentYujtix","disable":false,"name":"租金支付","child":[]},{"path":"warn_powerYujtix","disable":false,"name":"电费支付","child":[]}]}]},{"path":"","disable":false,"name":"票据回收","child":[{"path":"","disable":false,"name":"","child":[{"path":"warn_rentBill","disable":false,"name":"租金票据","child":[]},{"path":"warn_powerBill","disable":false,"name":"电费票据","child":[]},{"path":"warn_depositBill","disable":false,"name":"押金票据","child":[]}]}]},{"path":"/property/property/jzhtgl/jzht_renewal.jsp","disable":false,"name":"合同续签预警","child":[]},{"path":"#","disable":false,"name":"合同签署","child":[]},{"path":"#","disable":false,"name":"物业协调","child":[]}]}]},{"path":"","disable":false,"name":"统计查询","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"支付查询","child":[]},{"path":"/property/property/baseStation/multiquery2.jsp","disable":false,"name":"基站信息查询","child":[]},{"path":"/property/property/jzhtgl/jzhtinfo_seach.jsp","disable":false,"name":"合同信息查询","child":[]},{"path":"#","disable":false,"name":"基站信息统计","child":[]},{"path":"#","disable":false,"name":"合同信息统计","child":[]}]}]}]}]},{"path":"","disable":false,"name":"统计分析","child":[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"周报","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"断站周报","child":[]},{"path":"#","disable":false,"name":"在建工程周报","child":[]}]}]},{"path":"","disable":false,"name":"月报","child":[{"path":"","disable":false,"name":"","child":[{"path":"/property/property/baobiao/yuebao/cbjgxftop.jsp","disable":false,"name":"成本结构细分","child":[]},{"path":"#","disable":false,"name":"月成本支付分析","child":[]},{"path":"#","disable":false,"name":"累计成本执行月报","child":[]},{"path":"#","disable":false,"name":"在建工程进度月报","child":[]}]}]},{"path":"","disable":false,"name":"网优中心专项指标","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"规划选址","child":[]}]}]},{"path":"","disable":false,"name":"网络建设部专项指标","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"新建基站建设报表","child":[]}]}]},{"path":"","disable":false,"name":"运行维护部专项指标","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"运维报表","child":[]}]}]},{"path":"","disable":false,"name":"综合财务部专项指标","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"产权证明整理报表","child":[]}]}]},{"path":"","disable":false,"name":"专项","child":
[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"市电报装","child":[]},{"path":"#","disable":false,"name":"二房东改签","child":[]}]}]}]}]},{"path":"","disable":false,"name":"工单管理","child":[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"新建工
单","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"租金支付流程","child":[]},
{"path":"#","disable":false,"name":"电费支付流程","child":[]},{"path":"#","disable":false,"name":"管理费支付流程","child":[]},
{"path":"#","disable":false,"name":"押金支付流程","child":[]},{"path":"#","disable":false,"name":"其他费用流程","child":[]},
{"path":"#","disable":false,"name":"基站建设流程","child":[]},{"path":"#","disable":false,"name":"基站交接流程","child":[]},
{"path":"#","disable":false,"name":"客户投诉处理流程","child":[]},{"path":"#","disable":false,"name":"物业协调流程","child":[]},
{"path":"#","disable":false,"name":"基站拆搬迁流程","child":[]},{"path":"#","disable":false,"name":"合同汇签流程","child":[]}]}]},
{"path":"","disable":false,"name":"工单统计","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"工单
查询","child":[]},{"path":"#","disable":false,"name":"工单统计","child":[]}]}]},{"path":"#","disable":false,"name":"待办工单","child":[]},
{"path":"#","disable":false,"name":"在办工单","child":[]}]}]},
{"path":"","disable":false,"name":"客情管理","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/keqinggl/kehu_index.jsp","disable":false,"name":"客户基本信息管理","child":[]},
{"path":"/property/property/keqinggl/lxr_index.jsp","disable":false,"name":"联系人信息管理","child":[]},
{"path":"/property/property/keqinggl/kehuzh_index.jsp","disable":false,"name":"客户账号信息管理","child":[]},
{"path":"#","disable":false,"name":"客户维系管理","child":[]},{"path":"#","disable":false,"name":"客户投诉管理","child":[]}]}]},
{"path":"","disable":false,"name":"信息管理","child":[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"信息维
护","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/baseStation/erp/erplist.jsp","disable":false,"name":"erp机房站点申请","child":[]},
{"path":"/property/property/jzhtgl/jzht_index.jsp","disable":false,"name":"合同信息维护","child":[]},{"path":"","disable":false,"name":"费用
信息维护","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/costManage/rent/rentInfo_QueryJsp.jsp","disable":false,"name":"租金信息","child":[]},
{"path":"/property/property/costManage/powerRate/powerInfo_QueryJsp.jsp","disable":false,"name":"电费信息","child":[]},
{"path":"#","disable":false,"name":"押金信息","child":[]},{"path":"#","disable":false,"name":"管理费信息","child":[]},
{"path":"#","disable":false,"name":"其他费用信息","child":[]}]}]},{"path":"power_powerRateYuT","disable":false,"name":"电费预提","child":
[]},{"path":"/property/property/baseStation/list.jsp","disable":false,"name":"基站信息维护","child":[]}]}]},
{"path":"","disable":false,"name":"信息查询","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/baseStation/multiquery2.jsp","disable":false,"name":"基站信息查询","child":[]},
{"path":"/property/property/jzhtgl/jzhtinfo_seach.jsp","disable":false,"name":"合同信息查询","child":[]},{"path":"","disable":false,"name":"
费用信息查询","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/costManage/feiyongseach/yajingseach.jsp","disable":false,"name":"押金信息","child":[]},
{"path":"/property/property/costManage/feiyongseach/qitaseach.jsp","disable":false,"name":"其他费用","child":[]}]}]}]}]},
{"path":"","disable":false,"name":"财务管理","child":[{"path":"","disable":false,"name":"","child":[{"path":"","disable":false,"name":"台账管
理","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/costManage/feiyongseach/zujinseach.jsp","disable":false,"name":"租金台账","child":[]},
{"path":"/property/property/costManage/feiyongseach/dianfeiseach.jsp","disable":false,"name":"电费台账","child":[]},
{"path":"/property/property/costManage/feiyongseach/guanlifeiseach.jsp","disable":false,"name":"管理费台账","child":[]}]}]},
{"path":"","disable":false,"name":"扫描支付审核","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/costManage/feiyongseach/zjZfjhseach.jsp","disable":false,"name":"出纳租金导出","child":[]},
{"path":"/property/property/costManage/feiyongseach/dfZfjhseach.jsp","disable":false,"name":"出纳电费导出","child":[]}]}]}]}]}]}]},{"path":"","disable":false,"name":"系统管理","child":[{"path":"","disable":false,"name":"","child":
[{"path":"/property/property/log/logindex.jsp","disable":false,"name":"日志管理","child":[]},{"path":"#","disable":false,"name":"公告管理","child":[]},{"path":"bmlx_qyeryBmlx","disable":false,"name":"系统配置管理","child":[]},{"path":"/property/property/systemManage/qyxxbAdd.jsp","disable":false,"name":"区域配置管理","child":[]},{"path":"/property/property/zjzdjpz/zjzdj_index.jsp","disable":false,"name":"租金指导价配置管理","child":[]}]}]},{"path":"","disable":false,"name":"互动社区","child":[{"path":"","disable":false,"name":"","child":[{"path":"#","disable":false,"name":"互动社区","child":[]},{"path":"#","disable":false,"name":"代维抄表","child":[]}]}]}]}]

解决方案 »

  1.   


    package csdn;import org.json.JSONArray;public class Test {
    public static void main(String[] args) throws Exception {
    String s = "[{'path':'','disable':false,'name':'','child':[{'path':'','disable':false,'name':'首页','child':"
    +"[{'path':'','disable':false,'name':'','child':[{'path':'','disable':false,'name':'作业','child':"
    +"[{'path':'','disable':false,'name':'','child':[{'path':'','disable':false,'name':'费用支付','child':"
    +"[{'path':'','disable':false,'name':'','child':[{'path':'warn_rentYujtix','disable':false,'name':'租金支付','child':[]},"
    +"{'path':'warn_powerYujtix','disable':false,'name':'电费支付','child':[]}]}]}]}]}]}]}]}]";
    JSONArray ja = new JSONArray(s);
    System.out.println(ja);
    }
    }org.json.JSONArray有一个用字符串生成的构造
    不过你这个串似乎长了点,怕会有错误
      

  2.   

    JSONArray ja = new JSONArray(s);
    楼上 这个类 好像没有构造吧
      

  3.   

    你是不是说java没有这个包?这个包是引用的外部jar 
      

  4.   

    不可能呀  我也是用json这个转换类
      

  5.   

    org.json.JSONArray?
    json 有好多实现有jar包 不一样的
      

  6.   

    import net.sf.json.JSONArray;我用的是这个
      

  7.   

    net.sf.json就没有这个构造 
      

  8.   

    baidu
    一下 org.json 下载
    会有的 我下载了好久了 源地址忘了 或者给我邮箱 发给你
      

  9.   


    JSONArray ja = JSONArray.fromObject(s);
      

  10.   

    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.property.webservice.client.AuthServiceTest.testGetMenu(AuthServiceTest.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      

  11.   

    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    你的jar包加的不对。
      

  12.   

    下载的jar包截图在这里
    资料网站有各种“java处理JSON格式数据的通用类”http://canfly2010.javaeye.com/blog/545657其他的靠自学了,如果英文很好的话上官方网站去找资料。
    某个jar文件的用法不懂可以查看zip文件自带的javadoc文档。
    json的api不知道请上google搜索。
    还有什么比较重要问题请发帖。