C# JObject解析Json(多方法解析Json 二)

下载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();
上一篇:JavaScript笔记杂谈篇(啥都有)


下一篇:sql注入测试(4)--如何防止该类缺陷发生