树形结构的json字符串,如何变成json对象?
{status:"succeed",msg:"成功",
data:
[
{
"id":"1","name":"根目录","totalCount":12000,
child:
[
{
"id":"137","name":"服饰","totalCount":5000,
child:
[
{
"id":"140","name":"男装","totalCount":5000,
child:
[
{
"id":"141","name":"裤子","totalCount":5000
}
]
}
]
}
]
}
]
}
string value = "[{"id":0,"text":"自定义组视图"},{"id":-1,"text":"所有测点","iconCls":"ico_blank","children":";//[{"id":2,"text":"测点1"},{"id":3,"text":"测点2"},{"id":4,"text":"测点3"}]}]";
string children = "[";
for (int a = 0; a < spots.Rows.Count; a++)
{
if (a != spots.Rows.Count - 1)
{
children += "{"id":" + spots.Rows[a]["id"].ToString() + ","text":"" + spots.Rows[a]["name"] + ""},";
}
else
{
children += "{"id":" + spots.Rows[a]["id"].ToString() + ","text":"" + spots.Rows[a]["name"] + ""}";
}
}
children += "]";
value += children;
value += "}]";
context.Response.Clear();
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.ContentType = "application/json";
context.Response.Write(value);
context.Response.Flush();
context.Response.End();