Provides methods for converting between common language runtime types and JSON types.

Namespace: Newtonsoft.Json
Assembly: Newtonsoft.Json (in Newtonsoft.Json.dll) Version: 6.0.0.0 (6.0.1.17001)

Syntax

C#
public static class JsonConvert

Examples

Serializing and Deserializing JSON with JsonConvert Copy imageCopy
 1Product product = new Product();
 2
 3product.Name = "Apple";
 4product.ExpiryDate = new DateTime(2008, 12, 28);
 5product.Price = 3.99M;
 6product.Sizes = new string[] { "Small", "Medium", "Large" };
 7
 8string output = JsonConvert.SerializeObject(product);
 9//{
10//  "Name": "Apple",
11//  "ExpiryDate": "2008-12-28T00:00:00",
12//  "Price": 3.99,
13//  "Sizes": [
14//    "Small",
15//    "Medium",
16//    "Large"
17//  ]
18//}
19
20Product deserializedProduct = JsonConvert.DeserializeObject<Product>(output);

Inheritance Hierarchy

System..::..Object
  Newtonsoft.Json..::..JsonConvert

See Also