using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Globalization;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public string title { get; set; }
public int vote_count { get; set; }
public int id { get; set; }
public bool video { get; set; }
public double vote_average { get; set; }
public double popularity { get; set; }
public string poster_path { get; set; }
public string original_language { get; set; }
public string original_title { get; set; }
public List<object> genre_ids { get; set; }
public string backdrop_path { get; set; }
public bool adult { get; set; }
public string overview { get; set; }
public string release_date { get; set; }
public int page { get; set; }
public int total_results { get; set; }
public int total_pages { get; set; }
public List<Movie> results { get; set; }
public static void Test()
var movies1 = ExtractMoviesList(json);
Console.WriteLine("Extracted moviel titles using deserialization: ");
Console.WriteLine(JsonConvert.SerializeObject(movies1, Formatting.Indented));
var movies2 = ExtractMoviesListLinq(json);
Console.WriteLine("Extracted moviel titles using LINQ to JSON: ");
Console.WriteLine(JsonConvert.SerializeObject(movies2, Formatting.Indented));
Console.WriteLine("Input JSON: ");
static List<string> ExtractMoviesListLinq(string json)
var result = JToken.Parse(json);
return result.SelectTokens("results[*].title").Select(t => (string)t).ToList();
static List<string> ExtractMoviesList(string json)
var result = JsonConvert.DeserializeObject<RootObject>(json);
return result.results.Select(m => m.title).ToList();
""title"":""The Matrix"",
""poster_path"":""\/lZpWprJqbIFpEV5uoHfoK0KCnTW.jpg"",
""original_language"":""en"",
""original_title"":""The Matrix"",
""backdrop_path"":""\/7u3pxc0K1wx32IleAkLv78MKgrw.jpg"",
""overview"":""Set in the 22nd century, The Matrix tells the story of a computer hacker who joins a group of underground insurgents fighting the vast and powerful computers who now rule the earth."",
""release_date"":""1999-03-30""
""title"":""The Matrix Revolutions"",
""poster_path"":""\/sKogjhfs5q3azmpW7DFKKAeLEG8.jpg"",
""original_language"":""en"",
""original_title"":""The Matrix Revolutions"",
""backdrop_path"":""\/pdVHUsb2eEz9ALNTr6wfRJe5xVa.jpg"",
""overview"":""The human city of Zion defends itself against the massive invasion of the machines as Neo fights to end the war at another front while also opposing the rogue Agent Smith."",
""release_date"":""2003-11-05""
""poster_path"":""\/cseRq8R9RGN66SNUgcD7RJAxBI7.jpg"",
""original_language"":""en"",
""original_title"":""Matrix"",
""overview"":""John Whitney, Sr. (April 8, 1917 – September 22, 1995) was an American animator, composer and inventor, widely considered to be one of the fathers of computer animation."",
""release_date"":""1971-05-18""
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);