1
0
mirror of synced 2024-11-28 05:20:49 +01:00
TaikoSoundEditor/Json.cs

28 lines
735 B
C#
Raw Normal View History

2023-07-17 12:24:28 +02:00
using System.Diagnostics;
using System.Text.Encodings.Web;
2023-07-17 11:58:05 +02:00
using System.Text.Json;
using System.Text.Unicode;
2023-07-17 10:20:00 +02:00
namespace TaikoSoundEditor
{
internal static class Json
{
public static T Deserialize<T>(string json)
2023-07-19 07:10:25 +02:00
{
Logger.Info($"Deserializing {typeof(T)} ({json.Length})");
2023-07-17 10:20:00 +02:00
return JsonSerializer.Deserialize<T>(json);
}
public static string Serialize<T>(T item)
{
2023-07-19 07:10:25 +02:00
Logger.Info($"Serializing {typeof(T)}:\n{item}");
2023-07-17 11:58:05 +02:00
return JsonSerializer.Serialize(item, new JsonSerializerOptions
{
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All),
WriteIndented = true
});
2023-07-17 10:20:00 +02:00
}
}
}