mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-12 13:04:33 +01:00
32 lines
776 B
C#
32 lines
776 B
C#
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
|
|
namespace KianaBH.Database;
|
|
|
|
public class CustomSerializeService : ISerializeService
|
|
{
|
|
private readonly JsonSerializerSettings _jsonSettings;
|
|
|
|
public CustomSerializeService()
|
|
{
|
|
_jsonSettings = new JsonSerializerSettings
|
|
{
|
|
DefaultValueHandling = DefaultValueHandling.Ignore // ignore default values
|
|
};
|
|
}
|
|
|
|
public string SerializeObject(object value)
|
|
{
|
|
return JsonConvert.SerializeObject(value, _jsonSettings);
|
|
}
|
|
|
|
public T DeserializeObject<T>(string value)
|
|
{
|
|
return JsonConvert.DeserializeObject<T>(value)!;
|
|
}
|
|
|
|
public string SugarSerializeObject(object value)
|
|
{
|
|
return JsonConvert.SerializeObject(value, _jsonSettings);
|
|
}
|
|
} |