Add example_project

This commit is contained in:
JP Ungaretti 2023-03-01 08:10:34 +00:00
parent ab80288568
commit a091bc67dd
4 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bin
obj

View file

@ -0,0 +1,8 @@
// See https://aka.ms/new-console-template for more information
internal class Movie
{
public string Name { get; set; } = "Default Name";
public DateTime ReleaseDate { get; set; }
public List<string> Genres { get; set; } = new List<string>();
}

View file

@ -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)}");
}

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>