Fully remove the dependency on Newtonsoft.Json

This commit is contained in:
Daan Boerlage 2021-11-01 01:27:04 +01:00
parent cf0cd743b8
commit 8c2eabfd21
Signed by: daan
GPG key ID: FCE070E1E4956606
18 changed files with 92 additions and 22 deletions

View file

@ -28,7 +28,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-preview.2.21154.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-preview.2.21154.6" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0-preview.2.21154.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.2" />
<PackageReference Include="NLog.Config" Version="4.7.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0-preview2" />

View file

@ -5,7 +5,6 @@ using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Geekbot.Core
{
@ -39,7 +38,7 @@ namespace Geekbot.Core
httpClient.Dispose();
}
return JsonConvert.DeserializeObject<TResponse>(stringResponse);
return JsonSerializer.Deserialize<TResponse>(stringResponse);
}
public static async Task<TResponse> Post<TResponse>(Uri location, object data, HttpClient httpClient = null, bool disposeClient = true)
@ -48,7 +47,7 @@ namespace Geekbot.Core
httpClient.BaseAddress = location;
var content = new StringContent(
System.Text.Json.JsonSerializer.Serialize(data, new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }),
JsonSerializer.Serialize(data, new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }),
Encoding.UTF8,
"application/json"
);
@ -61,7 +60,7 @@ namespace Geekbot.Core
httpClient.Dispose();
}
return JsonConvert.DeserializeObject<TResponse>(stringResponse);
return JsonSerializer.Deserialize<TResponse>(stringResponse);
}
public static async Task Post(Uri location, object data, HttpClient httpClient = null, bool disposeClient = true)