mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
19 lines
604 B
C#
19 lines
604 B
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
namespace West.TelegramBot.ChatQuotes.Json
|
|
{
|
|
class NullToEmptyObjectResolver : DefaultContractResolver
|
|
{
|
|
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
|
{
|
|
return type.GetProperties()
|
|
.Select(p => {
|
|
var jp = base.CreateProperty(p, memberSerialization);
|
|
jp.ValueProvider = new NullToEmptyObjectValueProvider(p);
|
|
return jp;
|
|
}).ToList();
|
|
}
|
|
}
|
|
}
|