
·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> Json.Net
下载地址:Json.NET
文档地址:Json.NET Documentation
1 public class PRoduct
2 {
3 public string Name { get; set; }
4 public DateTime Expiry { get; set; }
5 public string[] Sizes { get; set; }
6 }
1 Product product = new Product();
2 product.Name = "Apple";
3 product.Expiry = new DateTime(2008, 12, 28);
4 product.Sizes = new string[] { "Small" };
5 string json = JsonConvert.SerializeObject(product);
6 Product result = JsonConvert.DeserializeObject<Product>(json);

1 public class Product
2 {
3 [JsonProperty("Name")]
4 public string ProName { get; set; }
5 [JsonProperty("Expiry")]
6 public DateTime ProExpiry { get; set; }
7 public string[] Sizes { get; set; }
8 }
1 string json = "{\"Name\":\"Apple\",\"Expiry\":\"2008-12-28T00:00:00\",\"Sizes\":[\"Small\"]}";
2 var product = JsonConvert.DeserializeObject<Product>(json);
3 var result = JsonConvert.SerializeObject(product);

SerializeXNode(DeserializeXNode)和SerializeXmlNode(DeserializeXmlNode)的使用方式基本一样

更多Json.NET信息,请查看官方文档吧