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;
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace Myriad.Serialization;
|
|
|
|
|
|
|
|
public static class JsonSerializerOptionsExtensions
|
2020-12-22 12:15:26 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
public static JsonSerializerOptions ConfigureForMyriad(this JsonSerializerOptions opts)
|
2020-12-22 12:15:26 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
opts.PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy();
|
|
|
|
opts.NumberHandling = JsonNumberHandling.AllowReadingFromString;
|
|
|
|
opts.IncludeFields = true;
|
2020-12-22 12:15:26 +00:00
|
|
|
|
2021-11-27 02:10:56 +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
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
return opts;
|
2020-12-22 12:15:26 +00:00
|
|
|
}
|
|
|
|
}
|