diff options
Diffstat (limited to 'test/dotnet/projects/netcoreapp3.1/Program.cs')
-rw-r--r-- | test/dotnet/projects/netcoreapp3.1/Program.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/dotnet/projects/netcoreapp3.1/Program.cs b/test/dotnet/projects/netcoreapp3.1/Program.cs new file mode 100644 index 0000000..3e088a9 --- /dev/null +++ b/test/dotnet/projects/netcoreapp3.1/Program.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +class Program +{ + public static void Main() + { + string json = @"{ + ""Name"": ""Inception"", + ""ReleaseDate"": ""2010-07-08T00:00:00"", + ""Genres"": [ + ""Action"", + ""Thriller"" + ] + }"; + + Movie? m = JsonConvert.DeserializeObject<Movie>(json); + + if (m == default) + { + Console.WriteLine("Decoding failed!"); + } + else + { + Console.WriteLine($"Movie name: {m.Name}"); + Console.WriteLine($"Release Date: {m.ReleaseDate}"); + Console.WriteLine($"Genres: {string.Join(", ", m.Genres)}"); + } + } +} + + +class Movie +{ + public string Name { get; set; } = "Default Name"; + public DateTime ReleaseDate { get; set; } + public List<string> Genres { get; set; } = new List<string>(); +} |