Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use System.Net.Http.Json #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/Balea.Api.Store/Extensions/HttpClientBuilderExtensions.cs

This file was deleted.

8 changes: 4 additions & 4 deletions src/Balea.Api.Store/Extensions/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Text.Json;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;

namespace System.Net.Http
{
public static class HttpClientExtensions
{
public static JsonSerializerOptions _serializationOptions = new JsonSerializerOptions()
public static readonly JsonSerializerOptions _serializationOptions = new JsonSerializerOptions()
{
AllowTrailingCommas = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
Expand All @@ -20,8 +21,7 @@ public static class HttpClientExtensions

public static async Task<TModel> GetJsonAsync<TModel>(this HttpClient client, string requestUri)
{
string json = await client.GetStringAsync(requestUri);
return JsonSerializer.Deserialize<TModel>(json, _serializationOptions);
return await client.GetFromJsonAsync<TModel>(requestUri, _serializationOptions);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Caching.Distributed
{
public static class DistributedCacheExtensions
{
public static JsonSerializerOptions _serializationOptions = new JsonSerializerOptions()
public static readonly JsonSerializerOptions _serializationOptions = new JsonSerializerOptions()
{
AllowTrailingCommas = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
Expand Down