using System; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; namespace Stone_Red_Utilities.Http { /// /// Extensions for /// public static class HttpClientExtentions { /// /// Reads the JSON returned from the website and converts it into an object /// /// /// The http client used for the request /// The Uri the request is sent to/> /// public static async Task GetJsonObjectAsync(this HttpClient httpClient, string requestUri) { return JsonSerializer.Deserialize(await httpClient.GetStringAsync(requestUri)); } /// /// Reads the JSON returned from the website and converts it into an object /// /// /// The http client used for the request /// The Uri the request is sent to/> /// public static async Task GetJsonObjectAsync(this HttpClient httpClient, Uri requestUri) { return JsonSerializer.Deserialize(await httpClient.GetStringAsync(requestUri)); } } }