Replace JSON.NET with System.Text.json (#840)

This commit is contained in:
RobertBeekman authored and GitHub committed 2024-02-28 19:31:38 +01:00
1 parent e112ca9da8
commit a340f8822e
63 files changed
+466 -584

No files matched your search

@@ -1,10 +1,9 @@
using System.IO.Compression;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using Artemis.Core;
using Artemis.UI.Shared.Utilities;
using Artemis.WebClient.Workshop.Entities;
using Artemis.WebClient.Workshop.Exceptions;
using Newtonsoft.Json;
using RGB.NET.Layout;
namespace Artemis.WebClient.Workshop.Handlers.UploadHandlers;
@@ -70,7 +69,7 @@ public class LayoutEntryUploadHandler : IEntryUploadHandler
if (!response.IsSuccessStatusCode)
return EntryUploadResult.FromFailure($"{response.StatusCode} - {await response.Content.ReadAsStringAsync(cancellationToken)}");
Release? release = JsonConvert.DeserializeObject<Release>(await response.Content.ReadAsStringAsync(cancellationToken));
Release? release = await response.Content.ReadFromJsonAsync<Release>(cancellationToken);
return release != null ? EntryUploadResult.FromSuccess(release) : EntryUploadResult.FromFailure("Failed to deserialize response");
}
@@ -1,6 +1,6 @@
using System.Net.Http.Headers;
using System.Net.Http.Json;
using Artemis.WebClient.Workshop.Entities;
using Newtonsoft.Json;
namespace Artemis.WebClient.Workshop.Handlers.UploadHandlers;
@@ -34,7 +34,7 @@ public class PluginEntryUploadHandler : IEntryUploadHandler
if (!response.IsSuccessStatusCode)
return EntryUploadResult.FromFailure($"{response.StatusCode} - {await response.Content.ReadAsStringAsync(cancellationToken)}");
Release? release = JsonConvert.DeserializeObject<Release>(await response.Content.ReadAsStringAsync(cancellationToken));
Release? release = await response.Content.ReadFromJsonAsync<Release>(cancellationToken);
return release != null ? EntryUploadResult.FromSuccess(release) : EntryUploadResult.FromFailure("Failed to deserialize response");
}
}
@@ -1,8 +1,7 @@
using System.Net.Http.Headers;
using System.Net.Http.Json;
using Artemis.Core.Services;
using Artemis.UI.Shared.Utilities;
using Artemis.WebClient.Workshop.Entities;
using Newtonsoft.Json;
namespace Artemis.WebClient.Workshop.Handlers.UploadHandlers;
@@ -39,7 +38,7 @@ public class ProfileEntryUploadHandler : IEntryUploadHandler
if (!response.IsSuccessStatusCode)
return EntryUploadResult.FromFailure($"{response.StatusCode} - {await response.Content.ReadAsStringAsync(cancellationToken)}");
Release? release = JsonConvert.DeserializeObject<Release>(await response.Content.ReadAsStringAsync(cancellationToken));
Release? release = await response.Content.ReadFromJsonAsync<Release>(cancellationToken);
return release != null ? EntryUploadResult.FromSuccess(release) : EntryUploadResult.FromFailure("Failed to deserialize response");
}
}