test.json文件数据如下,第一层是父节点,第二层是子节点children[ { "EndDate" : "2010-02-02",
"BaselineEndDate" : "2010-02-01",
    "Id" : 1,
    "Name" : "计划",
    "PercentDone" : 40,
    "Priority" : 1,
    "Responsible" : "",
    "StartDate" : "2010-01-18",
    "BaselineStartDate" : "2010-01-13",
    "expanded" : true,
"children" : [

"EndDate" : "2010-01-28",
"BaselineEndDate" : "2010-01-28",
"Id" : 11,
      "leaf" : true,
"Name" : "调研",
"ParentId" : 1,
"PercentDone" : 30,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-01-18",
"BaselineStartDate" : "2010-01-20"
},

"EndDate" : "2010-02-02",
"BaselineEndDate" : "2010-02-01",
"Id" : 12,
"leaf" : true,
"Name" : "分配资源",
"PercentDone" : 0,
"Priority" : 0,
"Responsible" : "",
"StartDate" : "2010-01-28",
"BaselineStartDate" : "2010-01-25"
},

"EndDate" : "2010-02-02",
"BaselineEndDate" : "2010-02-01",
"Id" : 13,
"leaf" : true,
"Name" : "收集文档",
"PercentDone" : 40,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-01-25",
"BaselineStartDate" : "2010-01-25"
},

"EndDate" : "2010-02-02",
"BaselineEndDate" : "2010-02-04",
"Id" : 17,
"leaf" : true,
"Name" : "汇报给领导",
"PercentDone" : 0,
"Priority" : 0,
"Responsible" : "",
"StartDate" : "2010-02-02",
"BaselineStartDate" : "2010-02-04"
}
]
  },
  { 
"EndDate" : "2010-03-20",
"BaselineEndDate" : "2010-03-15",
"Id" : 4,
"Name" : "实施阶段1",
"PercentDone" : 50,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-01-25",
"BaselineStartDate" : "2010-01-23",
    "expanded" : true,
"children" : [{ 
"EndDate" : "2010-01-30",
"BaselineEndDate" : "2010-01-25",
"Id" : 34,
"leaf" : true,
"Name" : "准备工作",
"PercentDone" : 0,
"Priority" : 0,
"Responsible" : "",
"StartDate" : "2010-01-25",
"BaselineStartDate" : "2010-01-20"
},

"EndDate" : "2010-03-07",
"BaselineEndDate" : "2010-03-07",
"Id" : 14,
"leaf" : true,
"Name" : "芯片评估",
"PercentDone" : 30,
"Priority" : 0,
"Responsible" : "",
"BaselineStartDate" : "2010-02-25",
"StartDate" : "2010-02-25"
},
{ "EndDate" : "2010-03-20",
"BaselineEndDate" : "2010-03-20",
"Id" : 16,
"leaf" : true,
"Name" : "选择技术方案",
"ParentId" : 4,
"PercentDone" : 30,
"Priority" : 0,
"Responsible" : "",
"BaselineStartDate" : "2010-03-10",
"StartDate" : "2010-03-10"
},

"EndDate" : "2010-03-08",
"BaselineEndDate" : "2010-03-06",
"Id" : 15,
"Name" : "设计原型",
"PercentDone" : 40,
"Priority" : 0,
"Responsible" : "",
"StartDate" : "2010-01-30",
"BaselineStartDate" : "2010-01-28",
"expanded" : true,
"children" : [

"EndDate" : "2010-02-09",
"BaselineEndDate" : "2010-02-06",
"Id" : 20,
"leaf" : true,
"Name" : "步骤 1",
"PercentDone" : 30,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-01-30",
"BaselineStartDate" : "2010-01-27"
},

"EndDate" : "2010-02-22",
"BaselineEndDate" : "2010-02-22",
"Id" : 19,
"leaf" : true,
"Name" : "步骤 2",
"PercentDone" : 40,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-02-17",
"BaselineStartDate" : "2010-02-17"
},

"EndDate" : "2010-03-07",
"BaselineEndDate" : "2010-03-07",
"Id" : 18,
"leaf" : true,
"Name" : "步骤 3",
"PercentDone" : 100,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-02-25",
"BaselineStartDate" : "2010-02-25"
  },
  { "EndDate" : "2010-03-08",
"BaselineEndDate" : "2010-03-08",
"Id" : 21,
"leaf" : true,
"Name" : "和用户沟通",
"PercentDone" : 60,
"Priority" : 0,
"Responsible" : "",
"StartDate" : "2010-03-04",
"BaselineStartDate" : "2010-03-04"
  }
]
}
]
  },
{  
"EndDate" : "2010-03-08",
"BaselineEndDate" : "2010-03-08",
"Id" : 5,
"leaf" : true,
"Name" : "用户签字确认",
"PercentDone" : 0,
"Priority" : 2,
"Responsible" : "",
"BaselineStartDate" : "2010-03-08",
"StartDate" : "2010-03-08"
},

"EndDate" : "2010-03-18",
"BaselineEndDate" : "2010-03-18",
"Id" : 6,
"Name" : "实施阶段 2",
"PercentDone" : 50,
"Priority" : 1,
"Responsible" : "",
"BaselineStartDate" : "2010-03-08",
"StartDate" : "2010-03-08",
        "expanded" : true,
"children" : [

"EndDate" : "2010-03-18",
"BaselineEndDate" : "2010-03-18",
"Id" : 25,
"leaf" : true,
"Name" : "任务 3",
"PercentDone" : 10,
"Priority" : 0,
"Responsible" : "",
"BaselineStartDate" : "2010-03-08",
"StartDate" : "2010-03-08"
  },
  { "EndDate" : "2010-03-18",
"BaselineEndDate" : "2010-03-18",
"Id" : 26,
"leaf" : true,
"Name" : "任务 2",
"ParentId" : 6,
"PercentDone" : 20,
"Priority" : 0,
"Responsible" : "",
"BaselineStartDate" : "2010-03-08",
"StartDate" : "2010-03-08"
  },
  { "EndDate" : "2010-03-18",
"BaselineEndDate" : "2010-03-18",
"Id" : 27,
"leaf" : true,
"Name" : "任务 1",
"ParentId" : 6,
"PercentDone" : 20,
"Priority" : 0,
"Responsible" : "",
"StartDate" : "2010-03-08",
"BaselineStartDate" : "2010-03-08"
  }
]
},

"EndDate" : "2010-03-17",
"BaselineEndDate" : "2010-03-17",
"Id" : 10,
"leaf" : true,
"Name" : "客户签字 2",
"PercentDone" : 0,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-03-17",
"BaselineStartDate" : "2010-03-17"
},

"EndDate" : "2010-05-08",
"BaselineEndDate" : "2010-05-08",
"Id" : 8,
"Name" : "生产阶段 1",
"PercentDone" : 40,
"Priority" : 2,
"Responsible" : "",
"StartDate" : "2010-03-22",
"BaselineStartDate" : "2010-03-22",
        "expanded" : true,
"children" : [

"EndDate" : "2010-04-07",
"BaselineEndDate" : "2010-04-07",
"Id" : 22,
"leaf" : true,
"Name" : "装配",
"PercentDone" : 50,
"Priority" : 1,
"Responsible" : "",
"StartDate" : "2010-03-22",
"BaselineStartDate" : "2010-03-22"
},

"EndDate" : "2010-04-21",
"BaselineEndDate" : "2010-04-21",
"Id" : 23,
"leaf" : true,
"Name" : "加载",
"PercentDone" : 20,
"Priority" : 2,
"Responsible" : "",
"StartDate" : "2010-04-06",
"BaselineStartDate" : "2010-04-06"
},

"EndDate" : "2010-05-08",
"BaselineEndDate" : "2010-05-04",
"Id" : 24,
"leaf" : true,
"Name" : "基本测试",
"PercentDone" : 50,
"Priority" : 2,
"Responsible" : "",
"BaselineStartDate" : "2010-04-14",
"StartDate" : "2010-04-22"
}
]
},

"EndDate" : "2010-05-15",
"BaselineEndDate" : "2010-05-11",
"Id" : 9,
"leaf" : true,
"Name" : "验收测试",
"PercentDone" : 0,
"Priority" : 1,
"Responsible" : "",
"BaselineStartDate" : "2010-05-02",
"StartDate" : "2010-05-07"
},

"EndDate" : "2010-05-15",
"BaselineEndDate" : "2010-05-11",
"Id" : 7,
"leaf" : true,
"Name" : "交付",
"PercentDone" : 40,
"Priority" : 1,
"Responsible" : "",
"BaselineStartDate" : "2010-05-11",
"StartDate" : "2010-05-15"
}
]

解决方案 »

  1.   

    可以详细一点吗?我现在只能读一层的。
    JSONArray array1 = JSONArray.fromObject(str); //str是json文件数据
                
                
                Iterator<JSONObject> iter = array1 .iterator();
              
                while (iter.hasNext()) {
                    JSONObject jsobj = iter.next();
                      String age =jsobj.getString("age");
                      obj = JSONObject.toBean(jsobj, User.class);  
                      list.add(obj);               }
      

  2.   

    已经调试了
    net.sf.json.JSONException: A JSONArray text must start with '[' at character 1 of ?[ { "EndDate" : "2010-02-02", "BaselineEndDate" : "2010-02-01",    "Id" : 1,    "Name" : "计划",    "PercentDone" : 40,    "Priority" : 1,    "Responsible" : "",    "StartDate" : "2010-01-18",    "BaselineStartDate" : "2010-01-13",    "expanded" : true, "children" : [ {  "EndDate" : "2010-01-28", "BaselineEndDate" : "2010-01-28", "Id" : 11,      "leaf" : true, "Name" : "调研", "ParentId" : 1, "PercentDone" : 30, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-01-18", "BaselineStartDate" : "2010-01-20" }, {  "EndDate" : "2010-02-02", "BaselineEndDate" : "2010-02-01", "Id" : 12, "leaf" : true, "Name" : "分配资源", "PercentDone" : 0, "Priority" : 0, "Responsible" : "", "StartDate" : "2010-01-28", "BaselineStartDate" : "2010-01-25" }, {  "EndDate" : "2010-02-02", "BaselineEndDate" : "2010-02-01", "Id" : 13, "leaf" : true, "Name" : "收集文档", "PercentDone" : 40, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-01-25", "BaselineStartDate" : "2010-01-25" }, {  "EndDate" : "2010-02-02", "BaselineEndDate" : "2010-02-04", "Id" : 17, "leaf" : true, "Name" : "汇报给领导", "PercentDone" : 0, "Priority" : 0, "Responsible" : "", "StartDate" : "2010-02-02", "BaselineStartDate" : "2010-02-04" } ]  },  {  "EndDate" : "2010-03-20", "BaselineEndDate" : "2010-03-15", "Id" : 4, "Name" : "实施阶段1", "PercentDone" : 50, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-01-25", "BaselineStartDate" : "2010-01-23",    "expanded" : true, "children" : [{  "EndDate" : "2010-01-30", "BaselineEndDate" : "2010-01-25", "Id" : 34, "leaf" : true, "Name" : "准备工作", "PercentDone" : 0, "Priority" : 0, "Responsible" : "", "StartDate" : "2010-01-25", "BaselineStartDate" : "2010-01-20" }, {  "EndDate" : "2010-03-07", "BaselineEndDate" : "2010-03-07", "Id" : 14, "leaf" : true, "Name" : "芯片评估", "PercentDone" : 30, "Priority" : 0, "Responsible" : "", "BaselineStartDate" : "2010-02-25", "StartDate" : "2010-02-25" }, { "EndDate" : "2010-03-20", "BaselineEndDate" : "2010-03-20", "Id" : 16, "leaf" : true, "Name" : "选择技术方案", "ParentId" : 4, "PercentDone" : 30, "Priority" : 0, "Responsible" : "", "BaselineStartDate" : "2010-03-10", "StartDate" : "2010-03-10" }, {  "EndDate" : "2010-03-08", "BaselineEndDate" : "2010-03-06", "Id" : 15, "Name" : "设计原型", "PercentDone" : 40, "Priority" : 0, "Responsible" : "", "StartDate" : "2010-01-30", "BaselineStartDate" : "2010-01-28", "expanded" : true, "children" : [ {  "EndDate" : "2010-02-09", "BaselineEndDate" : "2010-02-06", "Id" : 20, "leaf" : true, "Name" : "步骤 1", "PercentDone" : 30, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-01-30", "BaselineStartDate" : "2010-01-27" }, {  "EndDate" : "2010-02-22", "BaselineEndDate" : "2010-02-22", "Id" : 19, "leaf" : true, "Name" : "步骤 2", "PercentDone" : 40, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-02-17", "BaselineStartDate" : "2010-02-17" }, {  "EndDate" : "2010-03-07", "BaselineEndDate" : "2010-03-07", "Id" : 18, "leaf" : true, "Name" : "步骤 3", "PercentDone" : 100, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-02-25", "BaselineStartDate" : "2010-02-25"   },   { "EndDate" : "2010-03-08", "BaselineEndDate" : "2010-03-08", "Id" : 21, "leaf" : true, "Name" : "和用户沟通", "PercentDone" : 60, "Priority" : 0, "Responsible" : "", "StartDate" : "2010-03-04", "BaselineStartDate" : "2010-03-04"   } ] } ]  }, {   "EndDate" : "2010-03-08", "BaselineEndDate" : "2010-03-08", "Id" : 5, "leaf" : true, "Name" : "用户签字确认", "PercentDone" : 0, "Priority" : 2, "Responsible" : "", "BaselineStartDate" : "2010-03-08", "StartDate" : "2010-03-08" }, {  "EndDate" : "2010-03-18", "BaselineEndDate" : "2010-03-18", "Id" : 6, "Name" : "实施阶段 2", "PercentDone" : 50, "Priority" : 1, "Responsible" : "", "BaselineStartDate" : "2010-03-08", "StartDate" : "2010-03-08",        "expanded" : true, "children" : [ {  "EndDate" : "2010-03-18", "BaselineEndDate" : "2010-03-18", "Id" : 25, "leaf" : true, "Name" : "任务 3", "PercentDone" : 10, "Priority" : 0, "Responsible" : "", "BaselineStartDate" : "2010-03-08", "StartDate" : "2010-03-08"   },   { "EndDate" : "2010-03-18", "BaselineEndDate" : "2010-03-18", "Id" : 26, "leaf" : true, "Name" : "任务 2", "ParentId" : 6, "PercentDone" : 20, "Priority" : 0, "Responsible" : "", "BaselineStartDate" : "2010-03-08", "StartDate" : "2010-03-08"   },   { "EndDate" : "2010-03-18", "BaselineEndDate" : "2010-03-18", "Id" : 27, "leaf" : true, "Name" : "任务 1", "ParentId" : 6, "PercentDone" : 20, "Priority" : 0, "Responsible" : "", "StartDate" : "2010-03-08", "BaselineStartDate" : "2010-03-08"   } ] }, {  "EndDate" : "2010-03-17", "BaselineEndDate" : "2010-03-17", "Id" : 10, "leaf" : true, "Name" : "客户签字 2", "PercentDone" : 0, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-03-17", "BaselineStartDate" : "2010-03-17" }, {  "EndDate" : "2010-05-08", "BaselineEndDate" : "2010-05-08", "Id" : 8, "Name" : "生产阶段 1", "PercentDone" : 40, "Priority" : 2, "Responsible" : "", "StartDate" : "2010-03-22", "BaselineStartDate" : "2010-03-22",        "expanded" : true, "children" : [ {  "EndDate" : "2010-04-07", "BaselineEndDate" : "2010-04-07", "Id" : 22, "leaf" : true, "Name" : "装配", "PercentDone" : 50, "Priority" : 1, "Responsible" : "", "StartDate" : "2010-03-22", "BaselineStartDate" : "2010-03-22" }, {  "EndDate" : "2010-04-21", "BaselineEndDate" : "2010-04-21", "Id" : 23, "leaf" : true, "Name" : "加载", "PercentDone" : 20, "Priority" : 2, "Responsible" : "", "StartDate" : "2010-04-06", "BaselineStartDate" : "2010-04-06" }, {  "EndDate" : "2010-05-08", "BaselineEndDate" : "2010-05-04", "Id" : 24, "leaf" : true, "Name" : "基本测试", "PercentDone" : 50, "Priority" : 2, "Responsible" : "", "BaselineStartDate" : "2010-04-14", "StartDate" : "2010-04-22" } ] }, {  "EndDate" : "2010-05-15", "BaselineEndDate" : "2010-05-11", "Id" : 9, "leaf" : true, "Name" : "验收测试", "PercentDone" : 0, "Priority" : 1, "Responsible" : "", "BaselineStartDate" : "2010-05-02", "StartDate" : "2010-05-07" }, {  "EndDate" : "2010-05-15", "BaselineEndDate" : "2010-05-11", "Id" : 7, "leaf" : true, "Name" : "交付", "PercentDone" : 40, "Priority" : 1, "Responsible" : "", "BaselineStartDate" : "2010-05-11", "StartDate" : "2010-05-15" }]
    at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:527)
    at net.sf.json.JSONArray._fromJSONTokener(JSONArray.java:1146)
    at net.sf.json.JSONArray._fromString(JSONArray.java:1226)
    at net.sf.json.JSONArray.fromObject(JSONArray.java:151)
    at net.sf.json.JSONArray.fromObject(JSONArray.java:129)
    at kakarot.Util4JSON.getObjectFromFileOfJSON(Util4JSON.java:36)
    at kakarot.Test.main(Test.java:22)
      

  3.   

    你应该能得到children 里面的之把
    实在不行用str.split(",")切一下
      

  4.   

    split有例子吗?我看了个js的,好麻烦。
      

  5.   

    "d,d,d".split("'") 结果就是3个d的数组
      

  6.   

    我用的是org.json 测试了下没问题的
    JSONArray arr=new JSONArray(jsonStr);
    JSONObject obj=null;
    for(int i=0,l=arr.length();i<l;i++){
    obj=arr.getJSONObject(i);
    System.out.println(obj.get("Name"));
    }
    你那个json的第二个数据有3层
    还有你的代码和json对不上啊 里面哪有 age? 
      

  7.   

    回复antiwise,age是多余的,已经删掉了。我试试看
      

  8.   

    antiwise能把你的代码发到我邮箱吗?[email protected],谢谢
      

  9.   

    我原来这里的str是字符串型,报错了
      

  10.   

    str是字符串型 怎么个意思 不懂 
    发下代码看看
      

  11.   

    aa[i].children[i].key   2个循环就能实现。
      

  12.   


    package kakarot;import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.UnsupportedEncodingException;
    import java.util.ArrayList;
    import java.util.Iterator;import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
    import kakarot.User;
    public class Util4JSON
    {
        @SuppressWarnings("unchecked")
        public static Object getObjectFromFileOfJSON(String classPath,
                String encoding, Class clazz)
        {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            InputStream input = loader.getResourceAsStream(classPath);
            BufferedReader reader = null;
            Object obj = null;
            ArrayList list = new ArrayList();
            try {
                reader = new BufferedReader(new InputStreamReader(input, encoding));
                StringBuffer buffer = new StringBuffer();
                String line = reader.readLine(); // 读取第一行
                while (line != null) { // 如果 line 为空说明读完了
                    buffer.append(line); // 将读到的内容添加到 buffer 中
                    line = reader.readLine(); // 读取下一行
                }
                String str = buffer.toString();
                
                
                
                JSONArray array1 = JSONArray.fromObject(str); 
                int begin = 0;
                Iterator<JSONObject> iter = array1 .iterator();
                while (iter.hasNext()) {
                    JSONObject jsobj = iter.next();
                      obj = JSONObject.toBean(jsobj, task1.class);  
                      
                      list.add(obj);
                   }
                
             
    //            JSONObject obj1=null;
    //            for(int i=0,l=array1.size();i<l;i++){
    //                obj1=array1.getJSONObject(i);
    //                System.out.println(obj1.get("Name"));
    //            }
                
    //            JSONArray arr=new JSONArray(str);
    //            JSONObject obj=null;
    //            for(int i=0,l=arr.length();i<l;i++){
    //                obj=arr.getJSONObject(i);
    //                System.out.println(obj.get("Name"));
    //            }
                
                
                
    //            JSONObject object = (JSONObject)jsonData.get(0);
    //            obj = JSONObject.toBean(object, User.class);
    //            int a=1;
                
                
                //JSONObject object = JSONObject.fromObject(str);
               // obj = JSONObject.toBean(object, User.class);
            }
            catch (Exception e) {
                e.printStackTrace();
                obj = null;
                list =null;
            }
            return list;
        }
        
        public String asb(){
        
         return null;
        }
        
        
        
    }
      

  13.   


    package kakarot;import java.util.ArrayList;import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
    public class Test
    {
        public static void main(String[] args)
        {
            //User user = (User) Util4JSON.getObjectFromFileOfJSON("kakarot/test.json", "gb2312", User.class);
        
         //ArrayList list = (ArrayList)Util4JSON.getObjectFromFileOfJSON("kakarot/tasks.json", "gb2312", User.class);
        
        
         ArrayList list = (ArrayList)Util4JSON.getObjectFromFileOfJSON("kakarot/tree1.json", "gb2312", task1.class);
         for(int i=0;i<list.size();i++){
             //User user = (User)list.get(i); 
             task1 task1 = (task1)list.get(i); 
             System.out.println(task1.getName());
            }
        
            
    //        ArrayList list2 = (ArrayList) list.get(0);
    //        JSONObject jb = JSONObject.fromObject(list2);
    //        JSONArray array1 = jb.getJSONArray("children");
    //        int a=1;
            
            
            
        }
    }
      
      

  14.   


    package kakarot;public class task1 {
    String EndDate;
    String BaselineEndDate;
    int Id;
    String Name;
    String PercentDone;
    String Priority;
    String Responsible;
    String StartDate;
    String BaselineStartDate;
    String expanded;
    String children;

    public String getBaselineEndDate() {
    return BaselineEndDate;
    }
    public void setBaselineEndDate(String baselineEndDate) {
    BaselineEndDate = baselineEndDate;
    }
    public String getEndDate() {
    return EndDate;
    }
    public void setEndDate(String endDate) {
    EndDate = endDate;
    }
    public int getId() {
    return Id;
    }
    public void setId(int id) {
    Id = id;
    }
    public String getName() {
    return Name;
    }
    public void setName(String name) {
    Name = name;
    }
    public String getPercentDone() {
    return PercentDone;
    }
    public void setPercentDone(String percentDone) {
    PercentDone = percentDone;
    }
    public String getPriority() {
    return Priority;
    }
    public void setPriority(String priority) {
    Priority = priority;
    }
    public String getResponsible() {
    return Responsible;
    }
    public void setResponsible(String responsible) {
    Responsible = responsible;
    }
    public String getStartDate() {
    return StartDate;
    }
    public void setStartDate(String startDate) {
    StartDate = startDate;
    }
    public String getBaselineStartDate() {
    return BaselineStartDate;
    }
    public void setBaselineStartDate(String baselineStartDate) {
    BaselineStartDate = baselineStartDate;
    }
    public String getExpanded() {
    return expanded;
    }
    public void setExpanded(String expanded) {
    this.expanded = expanded;
    }
    public String getChildren() {
    return children;
    }
    public void setChildren(String children) {
    this.children = children;
    }

    }
      

  15.   

    net.sf.json.JSONException: A JSONArray text must start with '[' at character 1 of ?[ { "EndD
    你读出来的str 前面多了个?
    console里输出下 str 看看是不是
      

  16.   

    刚才是编码设置为gb2312的错,设为gbk再更正一下封装类task1就好了。确实有3层数据,刚才自己写了方法取出2层了,谢谢antiwise的提示
      

  17.   

    谢谢大家的支持,代码可以了。我对有无子节点做抛出异常处理。具体源代码上传到csdn.
    http://download.csdn.net/detail/a472198674/4086027