PluralKit/Myriad/Serialization/JsonSerializerOptionsExtensions.cs

20 lines
638 B
C#
Raw Normal View History

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