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.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<LocalesJSON>(fileData)!;
JsonSerializerOptions helperOptions = JsonHelper.GetDefaultSerializerOptions();
LocalesJSON json = JsonHelper.Deserialize(fileData, (JsonTypeInfo<LocalesJSON>)helperOptions.GetTypeInfo(typeof(LocalesJSON)));
foreach (LocalesEntry locale in json.Locales)
{

View file

@ -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<LocalesJSON>(languageJson);
JsonSerializerOptions helperOptions = JsonHelper.GetDefaultSerializerOptions();
LocalesJSON locales = JsonHelper.Deserialize(languageJson, (JsonTypeInfo<LocalesJSON>)helperOptions.GetTypeInfo(typeof(LocalesJSON)));
foreach (string language in locales.Languages)
{