Click or drag to resize
Json.NET

Write JSON text with JToken.ToString

 

This sample converts LINQ to JSON objects to JSON.

Sample
Usage
JObject o = JObject.Parse(@"{'string1':'value','integer2':99,'datetime3':'2000-05-23T00:00:00'}");

Console.WriteLine(o.ToString());
// {
//   "string1": "value",
//   "integer2": 99,
//   "datetime3": "2000-05-23T00:00:00"
// }

Console.WriteLine(o.ToString(Formatting.None));
// {"string1":"value","integer2":99,"datetime3":"2000-05-23T00:00:00"}

Console.WriteLine(o.ToString(Formatting.None, new JavaScriptDateTimeConverter()));
// {"string1":"value","integer2":99,"datetime3":new Date(959032800000)}