解析:{'id':'4028d80858053bed0158053ef7a50001','sl':0.0,'sfyfz':'0','zwjyzsbh':'1000001600000018'}
1、新建winform控制台項目
2、在項目裡新建一個實體類test.cs
class test { public string id { get; set; } public string sl { get; set; } public string sfyfz { get; set; } public string zwjyzsbh { get; set; } public string shlb { get; set; } public string zsh { get; set; } }
3、在Program.cs的Main方法裡(方法一)
class Program { static void Main(string[] args) { string json=@"[{'id':'22222222','sl':0.0,'sfyfz':'0','zwjyzsbh':'333333333'}]"; List<test> jobInfoList = JsonConvert.DeserializeObject<List<test>>(json); foreach (test jobInfo in jobInfoList) { Console.WriteLine("id:" + jobInfo.id); } Console.ReadLine(); } }
要引用Newtonsoft.Json(nuget下載)
3、在Program.cs的Main方法裡(方法二)
class Program { static void Main(string[] args) { string json = @"[{'id':'4028d80858053bed0158053ef7a50001','sl':0.0,'sfyfz':'0','zwjyzsbh':'1000001600000018'}]"; JsonReader reader = new JsonTextReader(new StringReader(json)); while (reader.Read()) { Console.WriteLine(reader.Value); } Console.ReadLine(); } }