@@ -56,7 +56,6 @@ public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS
5656 }
5757 }
5858 }
59-
6059 public override void Write ( Utf8JsonWriter writer , object value , JsonSerializerOptions options )
6160 {
6261 throw new NotImplementedException ( ) ;
@@ -91,12 +90,10 @@ internal override bool IsJsonNull(object jobject)
9190 {
9291 return jobject == null ;
9392 }
93+ static JsonSerializerOptions DeserializationOptions = new JsonSerializerOptions ( ) { Converters = { new GxJsonConverter ( ) } , AllowTrailingCommas = true } ;
9494 internal override T ReadJSON < T > ( string json )
9595 {
96- JsonSerializerOptions opts = new JsonSerializerOptions ( ) ;
97- opts . Converters . Add ( new GxJsonConverter ( ) ) ;
98- opts . AllowTrailingCommas = true ;
99- return JsonSerializer . Deserialize < T > ( json , opts ) ;
96+ return JsonSerializer . Deserialize < T > ( json , DeserializationOptions ) ;
10097 }
10198 internal override string WriteJSON < T > ( T kbObject )
10299 {
@@ -106,13 +103,13 @@ internal override string WriteJSON<T>(T kbObject)
106103 }
107104 return null ;
108105 }
106+ static JsonSerializerOptions JayrockCompatibleOptions = new JsonSerializerOptions ( ) {
107+ Encoder = JavaScriptEncoder . UnsafeRelaxedJsonEscaping ,
108+ Converters = { new CustomDateTimeConverter ( ) } ,
109+ NumberHandling = JsonNumberHandling . AllowNamedFloatingPointLiterals } ;
109110 internal static string SerializeToJayrockCompatibleJson < T > ( T value ) where T : IJayrockCompatible
110111 {
111- JsonSerializerOptions opts = new JsonSerializerOptions ( ) ;
112- opts . Encoder = JavaScriptEncoder . UnsafeRelaxedJsonEscaping ;
113- opts . Converters . Add ( new CustomDateTimeConverter ( ) ) ;
114- opts . NumberHandling = JsonNumberHandling . AllowNamedFloatingPointLiterals ;
115- return JsonSerializer . Serialize ( value , opts ) ;
112+ return JsonSerializer . Serialize ( value , JayrockCompatibleOptions ) ;
116113 }
117114 }
118115#else
0 commit comments