diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs index f9230e69..09cee0b5 100644 --- a/ASFEnhance/ASFEnhance.cs +++ b/ASFEnhance/ASFEnhance.cs @@ -1,4 +1,5 @@ using ArchiSteamFarm.Core; +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Plugins.Interfaces; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Web.GitHub.Data; @@ -72,7 +73,7 @@ public Task OnASFInit(IReadOnlyDictionary? additionalConfig { try { - config = JsonSerializer.Deserialize(configValue); + config = configValue.ToJsonObject(); if (config != null) { break; @@ -1154,7 +1155,7 @@ public Task OnLoaded() } catch (Exception ex) //错误日志 { - var cfg = JsonSerializer.Serialize(Config, DebugJsonOptions); + var cfg = Config.ToJsonText(); var sb = new StringBuilder(); sb.AppendLine(Langs.ErrorLogTitle); diff --git a/ASFEnhance/ASFEnhance.csproj b/ASFEnhance/ASFEnhance.csproj index dc59ca5c..ff597405 100644 --- a/ASFEnhance/ASFEnhance.csproj +++ b/ASFEnhance/ASFEnhance.csproj @@ -49,6 +49,11 @@ True + + + + + diff --git a/ASFEnhance/Account/HtmlParser.cs b/ASFEnhance/Account/HtmlParser.cs index 9b74f4c2..f65c56e0 100644 --- a/ASFEnhance/Account/HtmlParser.cs +++ b/ASFEnhance/Account/HtmlParser.cs @@ -1,11 +1,11 @@ using AngleSharp.Dom; using ArchiSteamFarm.Core; +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Web.Responses; using ASFEnhance.Data; using ASFEnhance.Data.Plugin; using System.Globalization; using System.Text; -using System.Text.Json; using static ASFEnhance.Account.CurrencyHelper; namespace ASFEnhance.Account; @@ -34,7 +34,7 @@ internal static class HtmlParser content = match.Groups[1].Value; try { - var cursorData = JsonSerializer.Deserialize(content, JsonOptions); + var cursorData = content.ToJsonObject(); return cursorData; } catch @@ -424,7 +424,7 @@ decimal ParseMoneyString(string strMoney) } try { - var optionsList = JsonSerializer.Deserialize>(payload, JsonOptions); + var optionsList = payload.ToJsonObject>(); if (optionsList == null) { return null; diff --git a/ASFEnhance/Account/WebRequest.cs b/ASFEnhance/Account/WebRequest.cs index 4f30333c..eee4d747 100644 --- a/ASFEnhance/Account/WebRequest.cs +++ b/ASFEnhance/Account/WebRequest.cs @@ -1,4 +1,5 @@ using ArchiSteamFarm.Core; +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Web.Responses; using ASFEnhance.Data; @@ -7,7 +8,6 @@ using ASFEnhance.Data.Plugin; using System.Net; using System.Text; -using System.Text.Json; using static ASFEnhance.Account.CurrencyHelper; namespace ASFEnhance.Account; @@ -301,7 +301,7 @@ internal static async Task RemoveLicense(Bot bot, uint subId) new(NotificationType.SteamTurnNotification,option.SteamTurnNotification), }; - var json = JsonSerializer.Serialize(optionList, JsonOptions); + var json = optionList.ToJsonText(); var data = new Dictionary(11) { { "notificationpreferences", json }, diff --git a/ASFEnhance/Cart/WebRequest.cs b/ASFEnhance/Cart/WebRequest.cs index 77657d4e..092cbd66 100644 --- a/ASFEnhance/Cart/WebRequest.cs +++ b/ASFEnhance/Cart/WebRequest.cs @@ -1,4 +1,5 @@ using ArchiSteamFarm.Core; +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Steam.Integration; using ArchiSteamFarm.Web.Responses; @@ -6,7 +7,6 @@ using ASFEnhance.Data.Common; using ASFEnhance.Data.IAccountCartService; using ASFEnhance.Data.Plugin; -using System.Text.Json; namespace ASFEnhance.Cart; internal static class WebRequest @@ -73,7 +73,7 @@ internal static class WebRequest }, }; - var json = JsonSerializer.Serialize(payload, JsonOptions); + var json = payload.ToJsonText(); var token = bot.AccessToken ?? throw new AccessTokenNullException(); var request = new Uri(SteamApiURL, $"/IAccountCartService/AddItemsToCart/v1/?access_token={token}"); var data = new Dictionary @@ -119,7 +119,7 @@ internal static class WebRequest }, }; - var json = JsonSerializer.Serialize(payload, JsonOptions); + var json = payload.ToJsonText(); var token = bot.AccessToken ?? throw new AccessTokenNullException(); var request = new Uri(SteamApiURL, $"/IAccountCartService/AddItemsToCart/v1/?access_token={token}"); var data = new Dictionary @@ -155,7 +155,7 @@ internal static class WebRequest }, }; - var json = JsonSerializer.Serialize(payload, JsonOptions); + var json = payload.ToJsonText(); var token = bot.AccessToken ?? throw new AccessTokenNullException(); var request = new Uri(SteamApiURL, $"/IAccountCartService/ModifyLineItem/v1/?access_token={token}"); var data = new Dictionary @@ -182,7 +182,7 @@ internal static class WebRequest UserCountry = WalletCurrency2UserCountry(bot.WalletCurrency), }; - var json = JsonSerializer.Serialize(payload, JsonOptions); + var json = payload.ToJsonText(); var token = bot.AccessToken ?? throw new AccessTokenNullException(); var request = new Uri(SteamApiURL, $"/IAccountCartService/RemoveItemFromCart/v1/?access_token={token}"); var data = new Dictionary diff --git a/ASFEnhance/Curator/HtmlParser.cs b/ASFEnhance/Curator/HtmlParser.cs index ea038fb0..1060c8ba 100644 --- a/ASFEnhance/Curator/HtmlParser.cs +++ b/ASFEnhance/Curator/HtmlParser.cs @@ -1,5 +1,5 @@ +using ArchiSteamFarm.Helpers.Json; using ASFEnhance.Data; -using System.Text.Json; using System.Text.RegularExpressions; namespace ASFEnhance.Curator; @@ -25,7 +25,7 @@ internal static class HtmlParser try { string jsonStr = match.Groups[1].Value; - var data = JsonSerializer.Deserialize>(jsonStr, JsonOptions); + var data = jsonStr.ToJsonObject>(); return data; } catch (Exception ex) diff --git a/ASFEnhance/Data/IAccountCartService/RemoveLineItemRequest.cs b/ASFEnhance/Data/IAccountCartService/RemoveLineItemRequest.cs index cb3708fe..67421c42 100644 --- a/ASFEnhance/Data/IAccountCartService/RemoveLineItemRequest.cs +++ b/ASFEnhance/Data/IAccountCartService/RemoveLineItemRequest.cs @@ -1,4 +1,3 @@ -using ASFEnhance.Data.Common; using System.Text.Json.Serialization; namespace ASFEnhance.Data.IAccountCartService; diff --git a/ASFEnhance/Data/WebApi/AJaxFollowResponse.cs b/ASFEnhance/Data/WebApi/AJaxFollowResponse.cs index 4696dd4a..478a97e8 100644 --- a/ASFEnhance/Data/WebApi/AJaxFollowResponse.cs +++ b/ASFEnhance/Data/WebApi/AJaxFollowResponse.cs @@ -1,4 +1,3 @@ -using ArchiSteamFarm.Steam.Data; using ASFEnhance.Data.Common; using System.Text.Json.Serialization; diff --git a/ASFEnhance/Event/WebRequest.cs b/ASFEnhance/Event/WebRequest.cs index a13a46d8..e54c3ef8 100644 --- a/ASFEnhance/Event/WebRequest.cs +++ b/ASFEnhance/Event/WebRequest.cs @@ -1,9 +1,9 @@ using AngleSharp.Dom; using ArchiSteamFarm.Core; +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Steam; using ASFEnhance.Data; using System.Text; -using System.Text.Json; namespace ASFEnhance.Event; @@ -269,7 +269,7 @@ internal static async Task MakeWinterSteamAwardVote(Bot bot, int gameID, int cat var configEle = response?.Content?.QuerySelector("#application_config"); var config = configEle?.GetAttribute("data-steam_awards_config") ?? ""; - var data = JsonSerializer.Deserialize(config, JsonOptions); + var data = config.ToJsonObject(); if (data == null) { diff --git a/ASFEnhance/Explorer/Command.cs b/ASFEnhance/Explorer/Command.cs index 016dd85d..7085405c 100644 --- a/ASFEnhance/Explorer/Command.cs +++ b/ASFEnhance/Explorer/Command.cs @@ -3,7 +3,6 @@ using ArchiSteamFarm.Localization; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Steam.Storage; -using System.Text.Json; namespace ASFEnhance.Explorer; @@ -139,7 +138,7 @@ internal static class Command var newValue = bot.BotConfig.FarmingPreferences | BotConfig.EFarmingPreferences.AutoSteamSaleEvent; - var jsonObject = JsonSerializer.Deserialize>(currentJson, JsonUtilities.DefaultJsonSerialierOptions); + var jsonObject = currentJson.ToJsonObject>(); if (jsonObject != null) { if (jsonObject.ContainsKey("FarmingPreferences")) @@ -151,7 +150,7 @@ internal static class Command jsonObject.Add("FarmingPreferences", newValue); } - currentJson = JsonSerializer.Serialize(jsonObject, JsonUtilities.IndentedJsonSerialierOptions); + currentJson = jsonObject.ToJsonText(); } await File.WriteAllTextAsync(filePath, currentJson).ConfigureAwait(false); diff --git a/ASFEnhance/Inventory/WebRequest.cs b/ASFEnhance/Inventory/WebRequest.cs index c2747f4b..033d871a 100644 --- a/ASFEnhance/Inventory/WebRequest.cs +++ b/ASFEnhance/Inventory/WebRequest.cs @@ -1,6 +1,5 @@ using ArchiSteamFarm.Steam; using ASFEnhance.Data; -using ASFEnhance.Data.Common; namespace ASFEnhance.Inventory; diff --git a/ASFEnhance/Profile/WebRequest.cs b/ASFEnhance/Profile/WebRequest.cs index d70e4a7f..8db8c6cb 100644 --- a/ASFEnhance/Profile/WebRequest.cs +++ b/ASFEnhance/Profile/WebRequest.cs @@ -1,3 +1,4 @@ +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Steam.Integration; using ArchiSteamFarm.Web; @@ -8,7 +9,6 @@ using System.Net; using System.Net.Http.Headers; using System.Text; -using System.Text.Json; namespace ASFEnhance.Profile; @@ -294,7 +294,7 @@ internal static async Task CraftBadge(Bot bot, int appId, bool foil, int l try { - var payload = JsonSerializer.Deserialize(json, JsonOptions); + var payload = json.ToJsonObject(); return payload; } catch (Exception ex) diff --git a/ASFEnhance/Store/WebRequest.cs b/ASFEnhance/Store/WebRequest.cs index 461c0d1f..97d915f9 100644 --- a/ASFEnhance/Store/WebRequest.cs +++ b/ASFEnhance/Store/WebRequest.cs @@ -1,11 +1,10 @@ -using ArchiSteamFarm.Core; +using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Steam; using ASFEnhance.Data; using ASFEnhance.Data.Common; using ASFEnhance.Data.IStoreBrowseService; using ASFEnhance.Data.Plugin; using System.Text; -using System.Text.Json; namespace ASFEnhance.Store; @@ -247,7 +246,7 @@ internal static async Task RedeemPoints(this Bot bot, uint defId) }, }; - var json = JsonSerializer.Serialize(payload, JsonOptions); + var json = payload.ToJsonText(); var encJson = UrlEncode(json); var token = bot.AccessToken ?? throw new AccessTokenNullException(); var request = new Uri(SteamApiURL, $"/IStoreBrowseService/GetItems/v1/?access_token={token}&input_json={encJson}"); diff --git a/ASFEnhance/Update/WebRequest.cs b/ASFEnhance/Update/WebRequest.cs index 68061812..0870d60d 100644 --- a/ASFEnhance/Update/WebRequest.cs +++ b/ASFEnhance/Update/WebRequest.cs @@ -1,9 +1,5 @@ -using ArchiSteamFarm.Core; using ArchiSteamFarm.Web.GitHub; -using ArchiSteamFarm.Web.GitHub.Data; -using ArchiSteamFarm.Web.Responses; using ASFEnhance.Data; -using System.IO.Compression; namespace ASFEnhance.Update; diff --git a/ASFEnhance/Utils.cs b/ASFEnhance/Utils.cs index d8c57128..6e39a212 100644 --- a/ASFEnhance/Utils.cs +++ b/ASFEnhance/Utils.cs @@ -1,5 +1,4 @@ using ArchiSteamFarm.Core; -using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.NLog; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Steam.Integration; @@ -11,7 +10,6 @@ using System.Collections.ObjectModel; using System.Reflection; using System.Text; -using System.Text.Json; using static ArchiSteamFarm.Steam.Integration.ArchiWebHandler; namespace ASFEnhance; @@ -353,13 +351,6 @@ public static Task UrlPost(this ArchiWebHandler handler, bool allowSessionRefresh = true, CancellationToken cancellationToken = default) => handler.UrlPostWithSession(request, null, data, referer, requestOptions, ESession.None, checkSessionPreemptively, maxTries, rateLimitingDelay, allowSessionRefresh, cancellationToken); - /// - /// Json序列化设置 - /// - public static JsonSerializerOptions JsonOptions => JsonUtilities.DefaultJsonSerialierOptions; - - public static JsonSerializerOptions DebugJsonOptions => JsonUtilities.IndentedJsonSerialierOptions; - internal static string GetGifteeProfile(ulong accountId) { ulong steam32; diff --git a/ASFEnhance/WishList/WebRequest.cs b/ASFEnhance/WishList/WebRequest.cs index e659b85d..38d3e1cc 100644 --- a/ASFEnhance/WishList/WebRequest.cs +++ b/ASFEnhance/WishList/WebRequest.cs @@ -11,6 +11,7 @@ internal static class WebRequest /// /// /// + /// /// internal static async Task AddWishlist(this Bot bot, uint gameId, bool isAddWishlist) { diff --git a/Directory.Build.props b/Directory.Build.props index 0d4b0b0a..f8f33f10 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 2.2.0.0 + 2.2.0.1