Newtonsoft.Json 序列化反序列化_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > Newtonsoft.Json 序列化反序列化

Newtonsoft.Json 序列化反序列化

 2015/5/4 16:58:02  奮鬥的.NET  程序员俱乐部  我要评论(0)
  • 摘要:publicclassPeople{publicstringname{get;set;}publicstringage{get;set;}publicstringsex{get;set;}}List<People>list=newList<People>();list.Add(newPeople{name="Jane",age="18",sex="female"});list.Add(newPeople{name="Lucy",age="21",sex="female"
  • 标签:JSON JS 序列化

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);//反序列化

发表评论
用户名: 匿名