Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 673 Bytes

SerializeDictionary.md

File metadata and controls

25 lines (21 loc) · 673 Bytes

Serialize a Dictionary

This sample serializes a dictionary to JSON.

var points = new Dictionary<string, int>
{
    {"James", 9001},
    {"Jo", 3474},
    {"Jess", 11926}
};

var json = JsonConvert.SerializeObject(points, Formatting.Indented);

Console.WriteLine(json);
// {
//   "James": 9001,
//   "Jo": 3474,
//   "Jess": 11926
// }

snippet source | anchor