c# Json格式

时间:2022-02-14 07:52:45

string inputJsonString = @"[ {Name:‘zhu‘,classNum:‘1‘,id:‘1‘}, {Name:‘yu‘,classNum:‘2‘,id:‘2‘}, {Name:‘quan‘,classNum:‘1‘,id:‘2‘} ]"; JArray jsonObj = JArray.Parse(inputJsonString); List<student> objects = new List<student>(); objects = JsonConvert.DeserializeObject<List<student>>(inputJsonString); foreach(student item in objects) { Console.WriteLine("name:{0},classNum:{1},id:{2}", item.Name, item.classNum, item.id); }