1
0
mirror of synced 2025-02-17 11:18:33 +01:00

29 lines
762 B
C#
Raw Normal View History

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