//匿名对象序列化 var obj=new { Name = "张三", Age = 15 }; Console.WriteLine(JsonConvert.SerializeObject(obj)); //匿名集合序列化 List<object> list = new List<object>(); list.Add(new { Name = "张三", Age = 15 }); list.Add(new { Name = "张三2", Age = new {Add="重庆",Birth="2016-09-01" } }); Console.WriteLine(JsonConvert.SerializeObject(list));
时间: 2024-10-24 14:01:13