using System.Collections.Generic;
private static string _moviesJson = MoviesJsonProvider.GetMoviesJson();
public static void Main()
var options = new JsonSerializerOptions
PropertyNameCaseInsensitive = true,
Movie[] movies = JsonSerializer.Deserialize<Movie[]>(_moviesJson, options);
Console.WriteLine("*********** EXERCISE 1 OUTPUT **********");
Console.WriteLine(JsonSerializer.Serialize<Movie[]>(movies, new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine("*********** EXERCISE 2 OUTPUT **********");
Console.WriteLine(Exercise2.GetResult(movies));
Console.WriteLine("*********** EXERCISE 3 OUTPUT **********");
Console.WriteLine(Exercise3.GetResult(movies));
Console.WriteLine("*********** EXERCISE 4 OUTPUT **********");
Console.WriteLine(Exercise4.GetResult(movies));
public static class Exercise2
public static string GetResult(Movie[] movies)
public static class Exercise3
public static string GetResult(Movie[] movies)
public static class Exercise4
public static string GetResult(Movie[] movies)
public static class MoviesJsonProvider
private static string _moviesJson =
""title"": ""Dirty Dancing"",
""cast"": [""Jennifer Grey"", ""Patrick Swayze"", ""Jerry Orbach"", ""Cynthia Rhodes""],
""genres"": [""Drama"", ""Music"", ""Romance""]
""genres"": [""Action"", ""Thriller""]
""title"": ""Nobody's fool"",
""genres"": [""Comedy"", ""Drama""]
""title"": ""Pulp Fiction"",
""genres"": [""Crime"", ""Drama""]
""title"": ""Empire Records"",
""genres"": [""Comedy"", ""Drama"", ""Music""]
""genres"": [""Crime"", ""Drama"", ""Thriller""]
""title"": ""O Brother, Where Art Thou?"",
""genres"": [""Crime"", ""Drama"", ""Thriller""]
""title"": ""The Cabin in the Woods"",
""Joseph Gordon-Levitt"",
""genres"": [""Action"", ""Crime"", ""Drama""]
""genres"": [""Drama"", ""Science Fiction"", ""Thriller""]
""title"": ""The Giver"",
""cast"": [""Jeff Bridges"", ""Meryl Streep"", ""Brenton Thwaites"", ""Katie Holmes""],
""genres"": [""Science Fiction""]
""title"": ""Life After Beth"",
""cast"": [""Aubrey Plaza"", ""Dane DeHaan"", ""Anna Kendrick"", ""Molly Shannon""],
""title"": ""The One I Love"",
""cast"": [""Mark Duplass"", ""Ted Danson"", ""Elisabeth Moss""],
""genres"": [""Romance"", ""Comedy""]
""title"": ""If I Stay"",
""genres"": [""Romance""]
""title"": ""Love Is Strange"",
""cast"": [""John Lithgow"", ""Alfred Molina"", ""Marisa Tomei"", ""Charlie Tahan""],
""title"": ""Dolphin Tale 2"",
""title"": ""The SpongeBob Movie: Sponge Out of Water"",
""cast"": [""Antonio Banderas"", ""Tom Kenny"", ""Clancy Brown"", ""Rodger Bumpass""],
""genres"": [""Animated"", ""Adventure""]
""title"": ""The Voices"",
""cast"": [""Ryan Reynolds"", ""Anna Kendrick"", ""Gemma Arterton"", ""Jacki Weaver""],
""title"": ""Accidental Love"",
""cast"": [""Jessica Biel"", ""Catherine Keener"", ""James Marsden"", ""Tracy Morgan""],
""title"": ""Mary Poppins Returns"",
""genres"": [""Musical"", ""Fantasy""]
""Yahya Abdul-Mateen II"",
""genres"": [""Superhero"", ""Action"", ""Adventure""]
""title"": ""Bumblebee"",
""genres"": [""Action"", ""Adventure"", ""Science Fiction""]
""title"": ""Welcome to Marwen"",
""genres"": [""Fantasy"", ""Drama""]
""title"": ""Holmes and Watson"",
""genres"": [""Action"", ""Mystery"", ""Comedy""]
""title"": ""Destroyer"",
""genres"": [""Crime"", ""Thriller""]
public static string GetMoviesJson()