@@ -56,11 +56,11 @@ public override IValues Read(ref Utf8JsonReader reader, Type typeToConvert, Json
56
56
if ( tokenType == JsonTokenType . StartArray )
57
57
{
58
58
var unwrappedType = type . GetUnderlyingTypeFromNullable ( ) ;
59
- argument = ReadJsonArray ( token , unwrappedType ) ;
59
+ argument = ReadJsonArray ( token , unwrappedType , null , options ) ;
60
60
}
61
61
else
62
62
{
63
- argument = ParseTokenArguments ( token , tokenType , type ) ;
63
+ argument = ParseTokenArguments ( token , tokenType , type , options ) ;
64
64
}
65
65
}
66
66
else
@@ -75,7 +75,7 @@ public override IValues Read(ref Utf8JsonReader reader, Type typeToConvert, Json
75
75
var type = mainType . GenericTypeArguments [ i ] ;
76
76
var unwrappedType = type . GetUnderlyingTypeFromNullable ( ) ;
77
77
// only read as many items as there are tokens left
78
- var args = ReadJsonArray ( token , unwrappedType , count - total ) ;
78
+ var args = ReadJsonArray ( token , unwrappedType , count - total , options ) ;
79
79
80
80
if ( args != null && args . Count > 0 )
81
81
{
@@ -103,7 +103,7 @@ public override IValues Read(ref Utf8JsonReader reader, Type typeToConvert, Json
103
103
104
104
try
105
105
{
106
- var args = ParseTokenArguments ( token , tokenType , type ) ;
106
+ var args = ParseTokenArguments ( token , tokenType , type , options ) ;
107
107
108
108
if ( args != null )
109
109
{
@@ -211,7 +211,7 @@ public virtual void WriteObject(Utf8JsonWriter writer, object value, JsonSeriali
211
211
JsonSerializer . Serialize ( writer , value , value ? . GetType ( ) , options ) ;
212
212
}
213
213
214
- private static object ParseTokenArguments ( JsonElement token , JsonTokenType tokenType , Type type )
214
+ private static object ParseTokenArguments ( JsonElement token , JsonTokenType tokenType , Type type , JsonSerializerOptions options )
215
215
{
216
216
const string SCHEMA_ORG = "http://schema.org/" ;
217
217
const int SCHEMA_ORG_LENGTH = 18 ; // equivalent to "http://schema.org/".Length
@@ -230,42 +230,42 @@ private static object ParseTokenArguments(JsonElement token, JsonTokenType token
230
230
{
231
231
if ( tokenType == JsonTokenType . StartObject )
232
232
{
233
- args = ParseTokenObjectArguments ( token , type , unwrappedType ) ;
233
+ args = ParseTokenObjectArguments ( token , type , unwrappedType , options ) ;
234
234
}
235
235
else
236
236
{
237
- args = ParseTokenValueArguments ( token , tokenType , type , unwrappedType ) ;
237
+ args = ParseTokenValueArguments ( token , tokenType , type , unwrappedType , options ) ;
238
238
}
239
239
}
240
240
241
241
return args ;
242
242
}
243
243
244
- private static object ParseTokenObjectArguments ( JsonElement token , Type type , Type unwrappedType )
244
+ private static object ParseTokenObjectArguments ( JsonElement token , Type type , Type unwrappedType , JsonSerializerOptions options )
245
245
{
246
246
object args = null ;
247
247
var typeName = GetTypeNameFromToken ( token ) ;
248
248
if ( string . IsNullOrEmpty ( typeName ) )
249
249
{
250
- args = token . ToObject ( unwrappedType ) ;
250
+ args = token . ToObject ( unwrappedType , options ) ;
251
251
}
252
252
else if ( typeName == type . Name )
253
253
{
254
- args = token . ToObject ( type ) ;
254
+ args = token . ToObject ( type , options ) ;
255
255
}
256
256
else
257
257
{
258
258
var builtType = Type . GetType ( $ "{ NamespacePrefix } { typeName } ") ;
259
259
if ( builtType != null && type . GetTypeInfo ( ) . IsAssignableFrom ( builtType . GetTypeInfo ( ) ) )
260
260
{
261
- args = token . ToObject ( builtType ) ;
261
+ args = token . ToObject ( builtType , options ) ;
262
262
}
263
263
}
264
264
265
265
return args ;
266
266
}
267
267
268
- private static object ParseTokenValueArguments ( JsonElement token , JsonTokenType tokenType , Type type , Type unwrappedType )
268
+ private static object ParseTokenValueArguments ( JsonElement token , JsonTokenType tokenType , Type type , Type unwrappedType , JsonSerializerOptions options )
269
269
{
270
270
object args = null ;
271
271
if ( unwrappedType . IsPrimitiveType ( ) )
@@ -336,7 +336,7 @@ private static object ParseTokenValueArguments(JsonElement token, JsonTokenType
336
336
// }
337
337
else
338
338
{
339
- args = token . ToObject ( typeof ( object ) ) ;
339
+ args = token . ToObject ( typeof ( object ) , options ) ;
340
340
}
341
341
}
342
342
else if ( unwrappedType == typeof ( decimal ) )
@@ -426,7 +426,7 @@ private static object ParseTokenValueArguments(JsonElement token, JsonTokenType
426
426
{
427
427
if ( ! type . GetTypeInfo ( ) . IsInterface && ! type . GetTypeInfo ( ) . IsClass )
428
428
{
429
- args = token . ToObject ( classType ) ; // This is expected to throw on some case
429
+ args = token . ToObject ( classType , options ) ; // This is expected to throw on some case
430
430
}
431
431
}
432
432
}
@@ -451,7 +451,7 @@ private static Type ToClass(Type type)
451
451
return type ;
452
452
}
453
453
454
- private static IList ReadJsonArray ( JsonElement token , Type type , int ? count = null )
454
+ private static IList ReadJsonArray ( JsonElement token , Type type , int ? count , JsonSerializerOptions options )
455
455
{
456
456
var classType = ToClass ( type ) ;
457
457
var listType = typeof ( List < > ) . MakeGenericType ( type ) ; // always read into list of interfaces
@@ -469,7 +469,7 @@ private static IList ReadJsonArray(JsonElement token, Type type, int? count = nu
469
469
var typeName = GetTypeNameFromToken ( childToken ) ;
470
470
if ( string . IsNullOrEmpty ( typeName ) )
471
471
{
472
- var child = childToken . ToObject ( classType ) ;
472
+ var child = childToken . ToObject ( classType , options ) ;
473
473
var method = listType . GetRuntimeMethod ( nameof ( List < object > . Add ) , new [ ] { classType } ) ;
474
474
475
475
if ( method != null )
@@ -484,7 +484,7 @@ private static IList ReadJsonArray(JsonElement token, Type type, int? count = nu
484
484
var builtType = Type . GetType ( $ "{ NamespacePrefix } { typeName } ") ;
485
485
if ( builtType != null && type . GetTypeInfo ( ) . IsAssignableFrom ( builtType . GetTypeInfo ( ) ) )
486
486
{
487
- var child = ( Thing ) childToken . ToObject ( builtType ) ;
487
+ var child = ( Thing ) childToken . ToObject ( builtType , options ) ;
488
488
var method = listType . GetRuntimeMethod ( nameof ( List < object > . Add ) , new [ ] { classType } ) ;
489
489
490
490
if ( method != null )
0 commit comments