LootDumpProcessor/Serializers/Json/NewtonsoftJsonSerializer.cs
chomp 6e4c7abf73 dump-processor-cleanup (#6)
Co-authored-by: Alex <alex@dm-me-for-questions.com>
Reviewed-on: SPT-AKI/LootDumpProcessor#6
2024-04-16 18:29:40 +00:00

28 lines
701 B
C#

using LootDumpProcessor.Serializers.Json.Converters;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace LootDumpProcessor.Serializers.Json;
public class NewtonsoftJsonSerializer : IJsonSerializer
{
private static readonly JsonSerializerSettings _settings = new()
{
Converters =
{
new NewtonsoftJsonKeyConverter(),
new StringEnumConverter(),
new NewtonsoftDateTimeConverter()
}
};
public string Serialize<T>(T obj)
{
return JsonConvert.SerializeObject(obj, _settings);
}
public T? Deserialize<T>(string obj)
{
return JsonConvert.DeserializeObject<T>(obj, _settings);
}
}