Serializing Collections

April 6, 2024 ยท View on GitHub

This sample serializes a collection to JSON.

var videogames = new List<string>
{
    "Starcraft",
    "Halo",
    "Legend of Zelda"
};

var json = JsonConvert.SerializeObject(videogames);

Console.WriteLine(json);
// ["Starcraft","Halo","Legend of Zelda"]

snippet source | anchor