From b98e762df8e6bff8e87ea8316006febe06298f2d Mon Sep 17 00:00:00 2001 From: LotP1 Date: Mon, 16 Dec 2024 21:02:55 +0100 Subject: [PATCH] Use JsonHelper abstraction --- src/Ryujinx/Common/LocaleManager.cs | 5 ++++- src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx/Common/LocaleManager.cs b/src/Ryujinx/Common/LocaleManager.cs index 54a11c109..7a475e8b5 100644 --- a/src/Ryujinx/Common/LocaleManager.cs +++ b/src/Ryujinx/Common/LocaleManager.cs @@ -1,6 +1,7 @@ using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Common; using Ryujinx.Common.Logging; +using Ryujinx.Common.Utilities; using Ryujinx.UI.Common.Configuration; using System; using System.Collections.Concurrent; @@ -10,6 +11,7 @@ using System.IO; using System.Linq; using System.Text.Encodings.Web; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using System.Text.Unicode; namespace Ryujinx.Ava.Common.Locale @@ -158,7 +160,8 @@ namespace Ryujinx.Ava.Common.Locale return null; } - LocalesJSON json = JsonSerializer.Deserialize(fileData)!; + JsonSerializerOptions helperOptions = JsonHelper.GetDefaultSerializerOptions(); + LocalesJSON json = JsonHelper.Deserialize(fileData, (JsonTypeInfo)helperOptions.GetTypeInfo(typeof(LocalesJSON))); foreach (LocalesEntry locale in json.Locales) { diff --git a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs index 1b1a4b229..40bb01b08 100644 --- a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs +++ b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; namespace Ryujinx.Ava.UI.Views.Main { @@ -59,7 +60,8 @@ namespace Ryujinx.Ava.UI.Views.Main string languageJson = EmbeddedResources.ReadAllText(localePath); - LocalesJSON locales = JsonSerializer.Deserialize(languageJson); + JsonSerializerOptions helperOptions = JsonHelper.GetDefaultSerializerOptions(); + LocalesJSON locales = JsonHelper.Deserialize(languageJson, (JsonTypeInfo)helperOptions.GetTypeInfo(typeof(LocalesJSON))); foreach (string language in locales.Languages) {