11using System . Text . Json ;
2+ using System . Text . Json . Serialization ;
23
34namespace OpenShock . Common . JsonSerialization ;
45
56public static class JsonSettings
67{
7- public static readonly JsonSerializerOptions FlagCompatibleCaseInsensitive = new ( )
8+ private static void ConfigureBase ( JsonSerializerOptions options )
89 {
9- PropertyNameCaseInsensitive = true ,
10- Converters = { new FlagCompatibleJsonStringEnumConverter ( ) }
10+ options . PropertyNameCaseInsensitive = true ;
11+ options . PropertyNamingPolicy = JsonNamingPolicy . CamelCase ;
12+ options . Converters . Add ( new PermissionTypeConverter ( ) ) ;
13+ }
14+
15+ public static void HttpOptions ( Microsoft . AspNetCore . Http . Json . JsonOptions options )
16+ {
17+ ConfigureBase ( options . SerializerOptions ) ;
18+ options . SerializerOptions . Converters . Add ( new JsonStringEnumConverter ( ) ) ; // TODO: Why does this differ from the one below?
19+ }
20+
21+ public static void MvcOptions ( Microsoft . AspNetCore . Mvc . JsonOptions options )
22+ {
23+ ConfigureBase ( options . JsonSerializerOptions ) ;
24+ options . JsonSerializerOptions . Converters . Add ( new FlagCompatibleJsonStringEnumConverter ( ) ) ; // TODO: Why does this differ from the one above?
25+ }
26+
27+ public static readonly JsonSerializerOptions MailJetSettings = new ( )
28+ {
29+ PropertyNamingPolicy = JsonNamingPolicy . CamelCase
1130 } ;
1231
13- public static readonly JsonSerializerOptions CaseInsensitive = new ( )
32+ public static readonly JsonSerializerOptions LiveControlSettings = new ( ) // TODO: Why does this differ from the one below?
1433 {
1534 PropertyNameCaseInsensitive = true
1635 } ;
17-
18- public static readonly JsonSerializerOptions CamelCase = new ( )
36+ public static readonly JsonSerializerOptions LiveControlSettings2 = new ( ) // TODO: Why does this differ from the one above?
1937 {
20- PropertyNamingPolicy = JsonNamingPolicy . CamelCase
38+ PropertyNameCaseInsensitive = true ,
39+ Converters = { new FlagCompatibleJsonStringEnumConverter ( ) }
2140 } ;
2241}
0 commit comments