static async Task Main(string[] args) { ChuckNorris item; using var client = new HttpClient(); client.BaseAddress = new Uri("https://api.chucknorris.io"); client.DefaultRequestHeaders.Accept.ParseAdd("application/json"); var responseString = await client.GetStringAsync("/jokes/random"); item = ChuckNorris.FromJson(responseString); Console.Clear(); Console.WriteLine("Chuck Norris Joke:"); Console.WriteLine(); Console.WriteLine(item.Joke); }
public static string ToJson(this ChuckNorris self) => JsonConvert.SerializeObject(self, Converter.Settings);