Use the official JSON parser (#1151)

This remove Utf8son and JsonPrettyPrinter dependencies.

NOTE: the standard JSON parser doesn't support configurable
indentation, as a result, all the pretty printed JSON are indented with 2
spaces.
This commit is contained in:
Thog 2020-04-30 14:07:41 +02:00 committed by GitHub
parent 7ab3fccd4d
commit 886e42fb19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 388 additions and 396 deletions

View file

@ -1,5 +1,4 @@
using Gtk;
using JsonPrettyPrinterPlus;
using LibHac;
using LibHac.Common;
using LibHac.Fs;
@ -12,11 +11,9 @@ using Ryujinx.HLE.FileSystem;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Utf8Json;
using Utf8Json.Resolvers;
using GUI = Gtk.Builder.ObjectAttribute;
using JsonHelper = Ryujinx.Common.Utilities.JsonHelper;
namespace Ryujinx.Ui
{
@ -47,12 +44,9 @@ namespace Ryujinx.Ui
try
{
using (Stream stream = File.OpenRead(System.IO.Path.Combine(_virtualFileSystem.GetBasePath(), "games", _titleId, "updates.json")))
{
IJsonFormatterResolver resolver = CompositeResolver.Create(StandardResolver.AllowPrivateSnakeCase);
string path = System.IO.Path.Combine(_virtualFileSystem.GetBasePath(), "games", _titleId, "updates.json");
_titleUpdateWindowData = JsonSerializer.Deserialize<TitleUpdateMetadata>(stream, resolver);
}
_titleUpdateWindowData = JsonHelper.DeserializeFromFile<TitleUpdateMetadata>(path);
}
catch
{
@ -185,12 +179,9 @@ namespace Ryujinx.Ui
}
}
IJsonFormatterResolver resolver = CompositeResolver.Create(StandardResolver.AllowPrivateSnakeCase);
string path = System.IO.Path.Combine(_virtualFileSystem.GetBasePath(), "games", _titleId, "updates.json");
byte[] data = JsonSerializer.Serialize(_titleUpdateWindowData, resolver);
File.WriteAllText(path, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson());
File.WriteAllText(path, JsonHelper.Serialize(_titleUpdateWindowData, true));
MainWindow.UpdateGameTable();
Dispose();