首页 > 学院 > 开发设计 > 正文

Newtonsoft.Json 序列化反序列化

2019-11-17 02:24:35
字体:
来源:转载
供稿:网友

Newtonsoft.Json 序列化反序列化

public class People { public string name { get; set; } public string age { get; set; } public string sex { get; set; } }List<People> list = new List<People>(); list.Add(new People { name = "Jane", age = "18", sex = "female" }); list.Add(new People { name = "Lucy", age = "21", sex = "female" }); list.Add(new People { name = "Anne", age = "20", sex = "female" });

string str = JsonConvert.SerializeObject(list);//序列化 List<People> peopleList = JsonConvert.DeserializeObject<List<People>>(str);//反序列化


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表