Deserialize a Collection

April 6, 2024 ยท View on GitHub

This sample deserializes JSON into a collection.

var json = "['Starcraft','Halo','Legend of Zelda']";

var videogames = JsonConvert.DeserializeObject<List<string>>(json);

Console.WriteLine(string.Join(", ", videogames.ToArray()));
// Starcraft, Halo, Legend of Zelda

snippet source | anchor