首页

源码搜藏网

首页 > 开发教程 > 数据库 >

Json.NET - LINQ to JSON

创建时间:2013-05-06 17:44  

API: http://james.newtonking.com/projects/json/help/

Json.NET

The Json.NET library makes working with JavaScript and JSON formatted data in .NET simple. Quickly read and write JSON using the JsonReader and JsonWriter or serialize your .NET objects with a single method call using the JsonSerializer. 

Example

Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
 
string json = JavaScriptConvert.SerializeObject(product);
//{
//  "Name": "Apple",
//  "Expiry": new Date(1230422400000),
//  "Price": 3.99,
//  "Sizes": [
//    "Small",
//    "Medium",
//    "Large"
//  ]
/
        
    
上一篇:不能不说的C#特性-迭代器(下),yield以及流的延迟计算
下一篇:初识Parallel Extensions之PLINQ

相关内容

热门推荐