Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created September 13, 2022 15:50
Show Gist options
  • Save jskeet/badd19537b14588ce465a0259598135d to your computer and use it in GitHub Desktop.
Save jskeet/badd19537b14588ce465a0259598135d to your computer and use it in GitHub Desktop.
using Newtonsoft.Json;
class Data
{
public string Title { get; set; }
public DateTime SomeTimestamp { get; set; }
public List<int> Numbers { get; set; } = new List<int>();
}
class Program
{
static void Main()
{
Data data = JsonConvert.DeserializeObject<Data>("{\"title\":\"some title\",\"timestamp\":\"2022-01-01T00:00:00.000Z\",\"numbers\":[1,2,3]}");
Console.WriteLine($"Title: {data.Title}");
Console.WriteLine($"SomeTimestamp: {data.SomeTimestamp}");
Console.WriteLine($"Numbers: {string.Join(", ", data.Numbers)}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment