1
0
mirror of synced 2024-11-27 21:10:48 +01:00
TaikoSoundEditor/Json.cs
2023-07-19 08:10:25 +03:00

28 lines
735 B
C#

using System.Diagnostics;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
namespace TaikoSoundEditor
{
internal static class Json
{
public static T Deserialize<T>(string json)
{
Logger.Info($"Deserializing {typeof(T)} ({json.Length})");
return JsonSerializer.Deserialize<T>(json);
}
public static string Serialize<T>(T item)
{
Logger.Info($"Serializing {typeof(T)}:\n{item}");
return JsonSerializer.Serialize(item, new JsonSerializerOptions
{
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All),
WriteIndented = true
});
}
}
}