PluralKit/Myriad/Serialization/JsonSerializerOptionsExtensions.cs
2020-12-25 13:58:45 +01:00

21 lines
696 B
C#

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());
opts.Converters.Add(new OptionalConverterFactory());
return opts;
}
}
}