数组型Json解析之细节
Json解析之细节
,ONE Goal,ONE Passion!
--czfy
换新工作将近有半个月了,也终于适应了新的工作环境和工作模式.现在也有更多的时间来整理自己想要学习的东西了.
数组型的json数据,对于新学习编程的同学来说感觉不知道如何去解析,甚至连bean类都不知道该如何去写.我在以为同学那里拿到了一个数据源,下面接把解析过程中出现的问题写下来.
一: 开始解析
try {
//首先: 将数据源转化为JSONArray对象
JSONArray array = new JSONArray(JsonString.jsonArray);
for (int i = 0; i < array.length(); i++) { //遍历数组中的json
JSONObject obj = array.optJSONObject(i);//得到的obj
Gson gson = new Gson(); //使用gson去解析.
bean bean = gson.fromJson(obj + "", bean.class); //bean为json数据对应的一个bean类
//我们想拿到里层ChildrenBean的数据,可是这个数据源有事不对称的:在第3个{...}中是没有ChildrenBean的.所以我们要先判断一下,解析出来的每个子bean是否有ChildrenBean.下图可以看到数据结构效果:
List<com.example.bean.bean.ChildrenBean> children = bean.getChildren();
// 此时一定注意不要用 children.isEmpty()判断是否有children
if (null != children) {
for (int j = 0; j < children.size(); j++) {
//这样就能得到最里层的name了
String name = children.get(j).getName();
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
备注: 为什么不用children.isEmpty()判断是否有children
/**
* Returns whether this {@code List} contains no elements.
*
* @return {@code true} if this {@code List} has no elements, {@code false}
* otherwise.
* @see #size
*/
public boolean isEmpty();//这个方法时判断集合中是否有元素
如果这样使用:
List<com.example.bean.bean.ChildrenBean> children = bean.getChildren();
children.isEmpty();
// 当bean中没有children时,就变成了null.isEmpty();所以在这里不能用 children.isEmpty();而要用: null != children; 做判断
二 .另附数据源以及bean类
有些人对bean类的写法不是很清晰,认为凡是数据源的字段,bean类中必须全有,而且,没有的bean类中也不能有,其实不是这样的.bean类中字段可以比数据源多或者少.到那时如果你用到某个字段的话,bean类中一定要有,而且不能写错.对于你不想用的字段可以不写如bean类中.如果bean类中多写了一个字段,也没问题,无非是你不用资字段就行了.
bean类
/**
* BaselineEndDate : 2010-02-01
* BaselineStartDate : 2010-01-13
* EndDate : 2010-02-02
* Id : 1
* Name : 计划
* PercentDone : 40
* Priority : 1
* Responsible :
* StartDate : 2010-01-18
* children : [{"BaselineEndDate":"2010-01-28","BaselineStartDate":"2010-01-20","EndDate":"2010-01-28","Id":11,"Name":"调研","ParentId":1,"PercentDone":30,"Priority":1,"Responsible":"","StartDate":"2010-01-18","leaf":true},{"BaselineEndDate":"2010-02-01","BaselineStartDate":"2010-01-25","EndDate":"2010-02-02","Id":12,"Name":"分配资源","PercentDone":0,"Priority":0,"Responsible":"","StartDate":"2010-01-28","leaf":true},{"BaselineEndDate":"2010-02-01","BaselineStartDate":"2010-01-25","EndDate":"2010-02-02","Id":13,"Name":"收集文档","PercentDone":40,"Priority":1,"Responsible":"","StartDate":"2010-01-25","leaf":true},{"BaselineEndDate":"2010-02-04","BaselineStartDate":"2010-02-04","EndDate":"2010-02-02","Id":17,"Name":"汇报给领导","PercentDone":0,"Priority":0,"Responsible":"","StartDate":"2010-02-02","leaf":true}]
* expanded : true
*/
private String BaselineEndDate;
private String BaselineStartDate;
private String EndDate;
private int Id;
private String Name;
private int PercentDone;
private int Priority;
private String Responsible;
private String StartDate;
private boolean expanded;
/**
* BaselineEndDate : 2010-01-28
* BaselineStartDate : 2010-01-20
* EndDate : 2010-01-28
* Id : 11
* Name : 调研
* ParentId : 1
* PercentDone : 30
* Priority : 1
* Responsible :
* StartDate : 2010-01-18
* leaf : true
*/
private List<ChildrenBean> children;
public String getBaselineEndDate() {
return BaselineEndDate;
}
public void setBaselineEndDate(String BaselineEndDate) {
this.BaselineEndDate = BaselineEndDate;
}
public String getBaselineStartDate() {
return BaselineStartDate;
}
public void setBaselineStartDate(String BaselineStartDate) {
this.BaselineStartDate = BaselineStartDate;
}
public String getEndDate() {
return EndDate;
}
public void setEndDate(String EndDate) {
this.EndDate = EndDate;
}
public int getId() {
return Id;
}
public void setId(int Id) {
this.Id = Id;
}
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public int getPercentDone() {
return PercentDone;
}
public void setPercentDone(int PercentDone) {
this.PercentDone = PercentDone;
}
public int getPriority() {
return Priority;
}
public void setPriority(int Priority) {
this.Priority = Priority;
}
public String getResponsible() {
return Responsible;
}
public void setResponsible(String Responsible) {
this.Responsible = Responsible;
}
public String getStartDate() {
return StartDate;
}
public void setStartDate(String StartDate) {
this.StartDate = StartDate;
}
public boolean isExpanded() {
return expanded;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
public List<ChildrenBean> getChildren() {
return children;
}
public void setChildren(List<ChildrenBean> children) {
this.children = children;
}
public static class ChildrenBean {
private String BaselineEndDate;
private String BaselineStartDate;
private String EndDate;
private int Id;
private String Name;
private int ParentId;
private int PercentDone;
private int Priority;
private String Responsible;
private String StartDate;
private boolean leaf;
public String getBaselineEndDate() {
return BaselineEndDate;
}
public void setBaselineEndDate(String BaselineEndDate) {
this.BaselineEndDate = BaselineEndDate;
}
public String getBaselineStartDate() {
return BaselineStartDate;
}
public void setBaselineStartDate(String BaselineStartDate) {
this.BaselineStartDate = BaselineStartDate;
}
public String getEndDate() {
return EndDate;
}
public void setEndDate(String EndDate) {
this.EndDate = EndDate;
}
public int getId() {
return Id;
}
public void setId(int Id) {
this.Id = Id;
}
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public int getParentId() {
return ParentId;
}
public void setParentId(int ParentId) {
this.ParentId = ParentId;
}
public int getPercentDone() {
return PercentDone;
}
public void setPercentDone(int PercentDone) {
this.PercentDone = PercentDone;
}
public int getPriority() {
return Priority;
}
public void setPriority(int Priority) {
this.Priority = Priority;
}
public String getResponsible() {
return Responsible;
}
public void setResponsible(String Responsible) {
this.Responsible = Responsible;
}
public String getStartDate() {
return StartDate;
}
public void setStartDate(String StartDate) {
this.StartDate = StartDate;
}
public boolean isLeaf() {
return leaf;
}
public void setLeaf(boolean leaf) {
this.leaf = leaf;
}
}
原始数据源
[
{
"BaselineEndDate": "2010-02-01",
"BaselineStartDate": "2010-01-13",
"EndDate": "2010-02-02",
"Id": 1,
"Name": "计划",
"PercentDone": 40,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-01-18",
"children": [
{
"BaselineEndDate": "2010-01-28",
"BaselineStartDate": "2010-01-20",
"EndDate": "2010-01-28",
"Id": 11,
"Name": "调研",
"ParentId": 1,
"PercentDone": 30,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-01-18",
"leaf": true
},
{
"BaselineEndDate": "2010-02-01",
"BaselineStartDate": "2010-01-25",
"EndDate": "2010-02-02",
"Id": 12,
"Name": "分配资源",
"PercentDone": 0,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-01-28",
"leaf": true
},
{
"BaselineEndDate": "2010-02-01",
"BaselineStartDate": "2010-01-25",
"EndDate": "2010-02-02",
"Id": 13,
"Name": "收集文档",
"PercentDone": 40,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-01-25",
"leaf": true
},
{
"BaselineEndDate": "2010-02-04",
"BaselineStartDate": "2010-02-04",
"EndDate": "2010-02-02",
"Id": 17,
"Name": "汇报给领导",
"PercentDone": 0,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-02-02",
"leaf": true
}
],
"expanded": true
},
{
"BaselineEndDate": "2010-03-15",
"BaselineStartDate": "2010-01-23",
"EndDate": "2010-03-20",
"Id": 4,
"Name": "实施阶段1",
"PercentDone": 50,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-01-25",
"children": [
{
"BaselineEndDate": "2010-01-25",
"BaselineStartDate": "2010-01-20",
"EndDate": "2010-01-30",
"Id": 34,
"Name": "准备工作",
"PercentDone": 0,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-01-25",
"leaf": true
},
{
"BaselineEndDate": "2010-03-07",
"BaselineStartDate": "2010-02-25",
"EndDate": "2010-03-07",
"Id": 14,
"Name": "芯片评估",
"PercentDone": 30,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-02-25",
"leaf": true
},
{
"BaselineEndDate": "2010-03-20",
"BaselineStartDate": "2010-03-10",
"EndDate": "2010-03-20",
"Id": 16,
"Name": "选择技术方案",
"ParentId": 4,
"PercentDone": 30,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-03-10",
"leaf": true
},
{
"BaselineEndDate": "2010-03-06",
"BaselineStartDate": "2010-01-28",
"EndDate": "2010-03-08",
"Id": 15,
"Name": "设计原型",
"PercentDone": 40,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-01-30",
"children": [
{
"BaselineEndDate": "2010-02-06",
"BaselineStartDate": "2010-01-27",
"EndDate": "2010-02-09",
"Id": 20,
"Name": "步骤 1",
"PercentDone": 30,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-01-30",
"leaf": true
},
{
"BaselineEndDate": "2010-02-22",
"BaselineStartDate": "2010-02-17",
"EndDate": "2010-02-22",
"Id": 19,
"Name": "步骤 2",
"PercentDone": 40,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-02-17",
"leaf": true
},
{
"BaselineEndDate": "2010-03-07",
"BaselineStartDate": "2010-02-25",
"EndDate": "2010-03-07",
"Id": 18,
"Name": "步骤 3",
"PercentDone": 100,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-02-25",
"leaf": true
},
{
"BaselineEndDate": "2010-03-08",
"BaselineStartDate": "2010-03-04",
"EndDate": "2010-03-08",
"Id": 21,
"Name": "和用户沟通",
"PercentDone": 60,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-03-04",
"leaf": true
}
],
"expanded": true
}
],
"expanded": true
},
{
"BaselineEndDate": "2010-03-08",
"BaselineStartDate": "2010-03-08",
"EndDate": "2010-03-08",
"Id": 5,
"Name": "用户签字确认",
"PercentDone": 0,
"Priority": 2,
"Responsible": "",
"StartDate": "2010-03-08",
"leaf": true
},
{
"BaselineEndDate": "2010-03-18",
"BaselineStartDate": "2010-03-08",
"EndDate": "2010-03-18",
"Id": 6,
"Name": "实施阶段 2",
"PercentDone": 50,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-03-08",
"children": [
{
"BaselineEndDate": "2010-03-18",
"BaselineStartDate": "2010-03-08",
"EndDate": "2010-03-18",
"Id": 25,
"Name": "任务 3",
"PercentDone": 10,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-03-08",
"leaf": true
},
{
"BaselineEndDate": "2010-03-18",
"BaselineStartDate": "2010-03-08",
"EndDate": "2010-03-18",
"Id": 26,
"Name": "任务 2",
"ParentId": 6,
"PercentDone": 20,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-03-08",
"leaf": true
},
{
"BaselineEndDate": "2010-03-18",
"BaselineStartDate": "2010-03-08",
"EndDate": "2010-03-18",
"Id": 27,
"Name": "任务 1",
"ParentId": 6,
"PercentDone": 20,
"Priority": 0,
"Responsible": "",
"StartDate": "2010-03-08",
"leaf": true
}
],
"expanded": true
},
{
"BaselineEndDate": "2010-03-17",
"BaselineStartDate": "2010-03-17",
"EndDate": "2010-03-17",
"Id": 10,
"Name": "客户签字 2",
"PercentDone": 0,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-03-17",
"leaf": true
},
{
"BaselineEndDate": "2010-05-08",
"BaselineStartDate": "2010-03-22",
"EndDate": "2010-05-08",
"Id": 8,
"Name": "生产阶段 1",
"PercentDone": 40,
"Priority": 2,
"Responsible": "",
"StartDate": "2010-03-22",
"children": [
{
"BaselineEndDate": "2010-04-07",
"BaselineStartDate": "2010-03-22",
"EndDate": "2010-04-07",
"Id": 22,
"Name": "装配",
"PercentDone": 50,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-03-22",
"leaf": true
},
{
"BaselineEndDate": "2010-04-21",
"BaselineStartDate": "2010-04-06",
"EndDate": "2010-04-21",
"Id": 23,
"Name": "加载",
"PercentDone": 20,
"Priority": 2,
"Responsible": "",
"StartDate": "2010-04-06",
"leaf": true
},
{
"BaselineEndDate": "2010-05-04",
"BaselineStartDate": "2010-04-14",
"EndDate": "2010-05-08",
"Id": 24,
"Name": "基本测试",
"PercentDone": 50,
"Priority": 2,
"Responsible": "",
"StartDate": "2010-04-22",
"leaf": true
}
],
"expanded": true
},
{
"BaselineEndDate": "2010-05-11",
"BaselineStartDate": "2010-05-02",
"EndDate": "2010-05-15",
"Id": 9,
"Name": "验收测试",
"PercentDone": 0,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-05-07",
"leaf": true
},
{
"BaselineEndDate": "2010-05-11",
"BaselineStartDate": "2010-05-11",
"EndDate": "2010-05-15",
"Id": 7,
"Name": "交付",
"PercentDone": 40,
"Priority": 1,
"Responsible": "",
"StartDate": "2010-05-15",
"leaf": true
}
]
放入代码中转义之后的数据源
String jsonArray = "[
" +
" {
" +
" "BaselineEndDate": "2010-02-01",
" +
" "BaselineStartDate": "2010-01-13",
" +
" "EndDate": "2010-02-02",
" +
" "Id": 1,
" +
" "Name": "计划",
" +
" "PercentDone": 40,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-18",
" +
" "children": [
" +
" {
" +
" "BaselineEndDate": "2010-01-28",
" +
" "BaselineStartDate": "2010-01-20",
" +
" "EndDate": "2010-01-28",
" +
" "Id": 11,
" +
" "Name": "调研",
" +
" "ParentId": 1,
" +
" "PercentDone": 30,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-18",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-02-01",
" +
" "BaselineStartDate": "2010-01-25",
" +
" "EndDate": "2010-02-02",
" +
" "Id": 12,
" +
" "Name": "分配资源",
" +
" "PercentDone": 0,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-28",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-02-01",
" +
" "BaselineStartDate": "2010-01-25",
" +
" "EndDate": "2010-02-02",
" +
" "Id": 13,
" +
" "Name": "收集文档",
" +
" "PercentDone": 40,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-25",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-02-04",
" +
" "BaselineStartDate": "2010-02-04",
" +
" "EndDate": "2010-02-02",
" +
" "Id": 17,
" +
" "Name": "汇报给领导",
" +
" "PercentDone": 0,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-02-02",
" +
" "leaf": true
" +
" }
" +
" ],
" +
" "expanded": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-15",
" +
" "BaselineStartDate": "2010-01-23",
" +
" "EndDate": "2010-03-20",
" +
" "Id": 4,
" +
" "Name": "实施阶段1",
" +
" "PercentDone": 50,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-25",
" +
" "children": [
" +
" {
" +
" "BaselineEndDate": "2010-01-25",
" +
" "BaselineStartDate": "2010-01-20",
" +
" "EndDate": "2010-01-30",
" +
" "Id": 34,
" +
" "Name": "准备工作",
" +
" "PercentDone": 0,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-25",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-07",
" +
" "BaselineStartDate": "2010-02-25",
" +
" "EndDate": "2010-03-07",
" +
" "Id": 14,
" +
" "Name": "芯片评估",
" +
" "PercentDone": 30,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-02-25",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-20",
" +
" "BaselineStartDate": "2010-03-10",
" +
" "EndDate": "2010-03-20",
" +
" "Id": 16,
" +
" "Name": "选择技术方案",
" +
" "ParentId": 4,
" +
" "PercentDone": 30,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-10",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-06",
" +
" "BaselineStartDate": "2010-01-28",
" +
" "EndDate": "2010-03-08",
" +
" "Id": 15,
" +
" "Name": "设计原型",
" +
" "PercentDone": 40,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-30",
" +
" "children": [
" +
" {
" +
" "BaselineEndDate": "2010-02-06",
" +
" "BaselineStartDate": "2010-01-27",
" +
" "EndDate": "2010-02-09",
" +
" "Id": 20,
" +
" "Name": "步骤 1",
" +
" "PercentDone": 30,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-01-30",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-02-22",
" +
" "BaselineStartDate": "2010-02-17",
" +
" "EndDate": "2010-02-22",
" +
" "Id": 19,
" +
" "Name": "步骤 2",
" +
" "PercentDone": 40,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-02-17",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-07",
" +
" "BaselineStartDate": "2010-02-25",
" +
" "EndDate": "2010-03-07",
" +
" "Id": 18,
" +
" "Name": "步骤 3",
" +
" "PercentDone": 100,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-02-25",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-08",
" +
" "BaselineStartDate": "2010-03-04",
" +
" "EndDate": "2010-03-08",
" +
" "Id": 21,
" +
" "Name": "和用户沟通",
" +
" "PercentDone": 60,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-04",
" +
" "leaf": true
" +
" }
" +
" ],
" +
" "expanded": true
" +
" }
" +
" ],
" +
" "expanded": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-08",
" +
" "BaselineStartDate": "2010-03-08",
" +
" "EndDate": "2010-03-08",
" +
" "Id": 5,
" +
" "Name": "用户签字确认",
" +
" "PercentDone": 0,
" +
" "Priority": 2,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-08",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-18",
" +
" "BaselineStartDate": "2010-03-08",
" +
" "EndDate": "2010-03-18",
" +
" "Id": 6,
" +
" "Name": "实施阶段 2",
" +
" "PercentDone": 50,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-08",
" +
" "children": [
" +
" {
" +
" "BaselineEndDate": "2010-03-18",
" +
" "BaselineStartDate": "2010-03-08",
" +
" "EndDate": "2010-03-18",
" +
" "Id": 25,
" +
" "Name": "任务 3",
" +
" "PercentDone": 10,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-08",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-18",
" +
" "BaselineStartDate": "2010-03-08",
" +
" "EndDate": "2010-03-18",
" +
" "Id": 26,
" +
" "Name": "任务 2",
" +
" "ParentId": 6,
" +
" "PercentDone": 20,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-08",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-18",
" +
" "BaselineStartDate": "2010-03-08",
" +
" "EndDate": "2010-03-18",
" +
" "Id": 27,
" +
" "Name": "任务 1",
" +
" "ParentId": 6,
" +
" "PercentDone": 20,
" +
" "Priority": 0,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-08",
" +
" "leaf": true
" +
" }
" +
" ],
" +
" "expanded": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-03-17",
" +
" "BaselineStartDate": "2010-03-17",
" +
" "EndDate": "2010-03-17",
" +
" "Id": 10,
" +
" "Name": "客户签字 2",
" +
" "PercentDone": 0,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-17",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-05-08",
" +
" "BaselineStartDate": "2010-03-22",
" +
" "EndDate": "2010-05-08",
" +
" "Id": 8,
" +
" "Name": "生产阶段 1",
" +
" "PercentDone": 40,
" +
" "Priority": 2,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-22",
" +
" "children": [
" +
" {
" +
" "BaselineEndDate": "2010-04-07",
" +
" "BaselineStartDate": "2010-03-22",
" +
" "EndDate": "2010-04-07",
" +
" "Id": 22,
" +
" "Name": "装配",
" +
" "PercentDone": 50,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-03-22",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-04-21",
" +
" "BaselineStartDate": "2010-04-06",
" +
" "EndDate": "2010-04-21",
" +
" "Id": 23,
" +
" "Name": "加载",
" +
" "PercentDone": 20,
" +
" "Priority": 2,
" +
" "Responsible": "",
" +
" "StartDate": "2010-04-06",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-05-04",
" +
" "BaselineStartDate": "2010-04-14",
" +
" "EndDate": "2010-05-08",
" +
" "Id": 24,
" +
" "Name": "基本测试",
" +
" "PercentDone": 50,
" +
" "Priority": 2,
" +
" "Responsible": "",
" +
" "StartDate": "2010-04-22",
" +
" "leaf": true
" +
" }
" +
" ],
" +
" "expanded": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-05-11",
" +
" "BaselineStartDate": "2010-05-02",
" +
" "EndDate": "2010-05-15",
" +
" "Id": 9,
" +
" "Name": "验收测试",
" +
" "PercentDone": 0,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-05-07",
" +
" "leaf": true
" +
" },
" +
" {
" +
" "BaselineEndDate": "2010-05-11",
" +
" "BaselineStartDate": "2010-05-11",
" +
" "EndDate": "2010-05-15",
" +
" "Id": 7,
" +
" "Name": "交付",
" +
" "PercentDone": 40,
" +
" "Priority": 1,
" +
" "Responsible": "",
" +
" "StartDate": "2010-05-15",
" +
" "leaf": true
" +
" }
" +
"]";
ok! 查看gson解析,生成更多详情请移步: http://blog.csdn.net/fengltxx/article/details/49902659
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: java 解析Json对象(嵌套json数组)
- 下一篇: yii2.0系列三:url美化