Click or drag to resize
Json.NETSerialize a Dictionary
 

This sample serializes a dictionary to JSON.

Sample
Usage
 1Dictionary<string, int> points = new Dictionary<string, int>
 2{
 3    { "James", 9001 },
 4    { "Jo", 3474 },
 5    { "Jess", 11926 }
 6};
 7
 8string json = JsonConvert.SerializeObject(points, Formatting.Indented);
 9
10Console.WriteLine(json);
11// {
12//   "James": 9001,
13//   "Jo": 3474,
14//   "Jess": 11926
15// }