using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json.Converters;
public partial class CountryData
public string Name { get; set; }
[JsonProperty("topLevelDomain")]
public List<string> TopLevelDomain { get; set; }
[JsonProperty("alpha2Code")]
public string Alpha2Code { get; set; }
[JsonProperty("alpha3Code")]
public string Alpha3Code { get; set; }
[JsonProperty("callingCodes")]
public List<string> CallingCodes { get; set; }
[JsonProperty("capital")]
public string Capital { get; set; }
[JsonProperty("altSpellings")]
public List<string> AltSpellings { get; set; }
public string Region { get; set; }
[JsonProperty("subregion")]
public string Subregion { get; set; }
[JsonProperty("population")]
public long Population { get; set; }
public List<double> Latlng { get; set; }
[JsonProperty("demonym")]
public string Demonym { get; set; }
public double? Area { get; set; }
public double? Gini { get; set; }
[JsonProperty("timezones")]
public List<string> Timezones { get; set; }
[JsonProperty("borders")]
public List<string> Borders { get; set; }
[JsonProperty("nativeName")]
public string NativeName { get; set; }
[JsonProperty("numericCode")]
public string NumericCode { get; set; }
[JsonProperty("currencies")]
public List<Currency> Currencies { get; set; }
[JsonProperty("languages")]
public List<Language> Languages { get; set; }
[JsonProperty("translations")]
public Translations Translations { get; set; }
public Uri Flag { get; set; }
[JsonProperty("regionalBlocs")]
public List<RegionalBloc> RegionalBlocs { get; set; }
public string Cioc { get; set; }
public partial class Currency
public string Code { get; set; }
public string Name { get; set; }
public string Symbol { get; set; }
public partial class Language
[JsonProperty("iso639_1")]
public string Iso6391 { get; set; }
[JsonProperty("iso639_2")]
public string Iso6392 { get; set; }
public string Name { get; set; }
[JsonProperty("nativeName")]
public string NativeName { get; set; }
public partial class RegionalBloc
[JsonProperty("acronym")]
public string Acronym { get; set; }
public string Name { get; set; }
[JsonProperty("otherAcronyms")]
public List<string> OtherAcronyms { get; set; }
[JsonProperty("otherNames")]
public List<string> OtherNames { get; set; }
public partial class Translations
public string De { get; set; }
public string Es { get; set; }
public string Fr { get; set; }
public string Ja { get; set; }
public string It { get; set; }
public string Br { get; set; }
public string Pt { get; set; }
public string Nl { get; set; }
public string Hr { get; set; }
public string Fa { get; set; }
public partial class CountryData
public static List<CountryData> FromJson(string json) => JsonConvert.DeserializeObject<List<CountryData>>(json, QuickType.Converter.Settings);
public static class Serialize
public static string ToJson(this List<CountryData> self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
internal static class Converter
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
public static void Main()
using(WebClient wc = new WebClient())
json = wc.DownloadString("https://restcountries.eu/rest/v2/all");
List<CountryData> data = CountryData.FromJson(json);
Console.WriteLine(data.Count);