C# 獲取Json中的List

參考地址

using System.Runtime.Serialization;
using System.Web.Script.Serialization;



{"Total":"0",
"Rows":
[
{
"id":"31",
"project":"6",
"project_name":"測試",
"name":"哈哈!",
"assignedTo":"liming",
"realname":"李明",
"estStarted":"2016/11/23",
"realStarted":"2000/01/01",
"status":"wait"
},
{
"id":"32",
"project":"6",
"project_name":"嘻嘻",
"name":"你好",
"assignedTo":"wangwu",
"realname":"王五",
"estStarted":"2016/11/23",
"realStarted":"2016/11/23",
"status":"wait"
}
]}

int IndexofA = jsonText.IndexOf("[");
int IndexofB = jsonText.IndexOf("]");
string Ru = jsonText.Substring(IndexofA , IndexofB - IndexofA+1);



JavaScriptSerializer Serializer = new JavaScriptSerializer();
List<Test> objs = Serializer.Deserialize<List<Test>>(Ru);



//實體類

 public class Test
        {
            public int id { get; set; }
            public string project { get; set; }
            public string project_name { get; set; }
            public string name { get; set; }
            public string assignedTo { get; set; }
            public string realname{ get; set; }
            public string estStarted { get; set; }
            public string realStarted { get; set; }
            public string status { get; set; }
        }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章