PluralKit/Myriad/Serialization/JsonSerializerOptionsExtensions.cs

21 lines
696 B
C#
Raw Normal View History

2020-12-22 12:15:26 +00:00
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Myriad.Serialization
{
public static class JsonSerializerOptionsExtensions
{
public static JsonSerializerOptions ConfigureForNewcord(this JsonSerializerOptions opts)
{
opts.PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy();
opts.NumberHandling = JsonNumberHandling.AllowReadingFromString;
opts.IncludeFields = true;
opts.Converters.Add(new PermissionSetJsonConverter());
opts.Converters.Add(new ShardInfoJsonConverter());
2020-12-25 12:58:45 +00:00
opts.Converters.Add(new OptionalConverterFactory());
2020-12-22 12:15:26 +00:00
return opts;
}
}
}