2023-08-13 17:26:49 +01:00
|
|
|
|
using LootDumpProcessor.Serializers.Json.Converters;
|
2023-08-12 19:08:38 +01:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
|
|
|
|
|
|
namespace LootDumpProcessor.Serializers.Json;
|
|
|
|
|
|
|
|
|
|
public class NewtonsoftJsonSerializer : IJsonSerializer
|
|
|
|
|
{
|
|
|
|
|
private static readonly JsonSerializerSettings _settings = new JsonSerializerSettings
|
|
|
|
|
{
|
|
|
|
|
Converters =
|
|
|
|
|
{
|
|
|
|
|
new NewtonsoftJsonKeyConverter(),
|
2023-08-13 17:26:49 +01:00
|
|
|
|
new StringEnumConverter(),
|
|
|
|
|
new NewtonsoftDateTimeConverter()
|
2023-08-12 19:08:38 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public string Serialize<T>(T obj)
|
|
|
|
|
{
|
|
|
|
|
return JsonConvert.SerializeObject(obj, _settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T Deserialize<T>(string obj)
|
|
|
|
|
{
|
|
|
|
|
return JsonConvert.DeserializeObject<T>(obj, _settings);
|
|
|
|
|
}
|
|
|
|
|
}
|