下载Newtonsoft.Json,添加引用

记得using Newtonsoft.Json.Linq;

//用JObject解析
            string json = "{\"offlineLock\":{\"id\":\"4028d808581dab0f01581db51405001e\",\"mac\":\"D4:3D:7E:5F:B7:44\",\"sdsl\":5,\"sdrq\":1477967156304,\"shlb\":\"0\"},\"flag\":\"success\",\"status\":\"1400\",\"resultList\":[{\"id\":\"4028d808581dab0f01581db5145c001f\",\"zwjyzsbh\":\"1000001600000052\",\"sfyfz\":\"0\"},{\"id\":\"4028d808581dab0f01581db514780020\",\"zwjyzsbh\":\"1000001600000054\",\"sfyfz\":\"0\"},{\"id\":\"4028d808581dab0f01581db514950021\",\"zwjyzsbh\":\"1000001600000056\",\"sfyfz\":\"0\"},{\"id\":\"4028d808581dab0f01581db514b20022\",\"zwjyzsbh\":\"1000001600000058\",\"sfyfz\":\"0\"},{\"id\":\"4028d808581dab0f01581db514cc0023\",\"zwjyzsbh\":\"1000001600000060\",\"sfyfz\":\"0\"}]}";

            JObject jo = (JObject)JsonConvert.DeserializeObject(json);
            string id = jo["offlineLock"]["id"].ToString();
            Console.WriteLine(id);

            Console.ReadLine();

 

 posted on 2016-11-01 15:17  布鲁布鲁sky  阅读(14275)  评论(0编辑  收藏  举报