diff options
Diffstat (limited to 'test/dotnet/example_project/Program.cs')
-rw-r--r-- | test/dotnet/example_project/Program.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/dotnet/example_project/Program.cs b/test/dotnet/example_project/Program.cs new file mode 100644 index 0000000..7beb65f --- /dev/null +++ b/test/dotnet/example_project/Program.cs @@ -0,0 +1,27 @@ +// See https://aka.ms/new-console-template for more information
+
+using Newtonsoft.Json;
+
+Console.WriteLine("Hello, World!");
+
+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($"Name: {m.Name}");
+ Console.WriteLine($"Release Date: {m.ReleaseDate}");
+ Console.WriteLine($"Genres: {string.Join(", ", m.Genres)}");
+}
|