Use JsonHelper abstraction

This commit is contained in:
LotP1 2024-12-16 21:02:55 +01:00
parent 611a11ab56
commit b98e762df8
2 changed files with 7 additions and 2 deletions

View file

@ -1,6 +1,7 @@
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
using Ryujinx.UI.Common.Configuration; using Ryujinx.UI.Common.Configuration;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -10,6 +11,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using System.Text.Unicode; using System.Text.Unicode;
namespace Ryujinx.Ava.Common.Locale namespace Ryujinx.Ava.Common.Locale
@ -158,7 +160,8 @@ namespace Ryujinx.Ava.Common.Locale
return null; return null;
} }
LocalesJSON json = JsonSerializer.Deserialize<LocalesJSON>(fileData)!; JsonSerializerOptions helperOptions = JsonHelper.GetDefaultSerializerOptions();
LocalesJSON json = JsonHelper.Deserialize(fileData, (JsonTypeInfo<LocalesJSON>)helperOptions.GetTypeInfo(typeof(LocalesJSON)));
foreach (LocalesEntry locale in json.Locales) foreach (LocalesEntry locale in json.Locales)
{ {

View file

@ -21,6 +21,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
namespace Ryujinx.Ava.UI.Views.Main namespace Ryujinx.Ava.UI.Views.Main
{ {
@ -59,7 +60,8 @@ namespace Ryujinx.Ava.UI.Views.Main
string languageJson = EmbeddedResources.ReadAllText(localePath); string languageJson = EmbeddedResources.ReadAllText(localePath);
LocalesJSON locales = JsonSerializer.Deserialize<LocalesJSON>(languageJson); JsonSerializerOptions helperOptions = JsonHelper.GetDefaultSerializerOptions();
LocalesJSON locales = JsonHelper.Deserialize(languageJson, (JsonTypeInfo<LocalesJSON>)helperOptions.GetTypeInfo(typeof(LocalesJSON)));
foreach (string language in locales.Languages) foreach (string language in locales.Languages)
{ {