@@ -201,7 +201,7 @@ public virtual void WriteObject(Utf8JsonWriter writer, object? value, JsonSerial
201
201
var targetType = targetTypes [ i ] ;
202
202
if ( targetType . IsAssignableFrom ( explicitType ) )
203
203
{
204
- return ProcessObject ( objectRoot , explicitType ! , options ) ;
204
+ return objectRoot . Deserialize ( explicitType ! , options ) ;
205
205
}
206
206
}
207
207
}
@@ -224,7 +224,7 @@ public virtual void WriteObject(Utf8JsonWriter writer, object? value, JsonSerial
224
224
localTargetType = concreteType ! ;
225
225
}
226
226
227
- return ProcessObject ( objectRoot , localTargetType , options ) ;
227
+ return objectRoot . Deserialize ( localTargetType , options ) ;
228
228
}
229
229
#pragma warning disable CA1031 // Do not catch general exception types
230
230
catch ( Exception ex )
@@ -489,13 +489,5 @@ private static bool TryGetConcreteType(
489
489
#pragma warning restore CA1031 // Do not catch general exception types
490
490
}
491
491
}
492
-
493
- private static object ? ProcessObject ( JsonElement element , Type objectType , JsonSerializerOptions options )
494
- {
495
- // TODO: Investigate avoiding the string allocation
496
- // Related issue: https://github.com/dotnet/runtime/issues/31274
497
- var json = element . GetRawText ( ) ;
498
- return JsonSerializer . Deserialize ( json , objectType ?? typeof ( object ) , options ) ;
499
- }
500
492
}
501
493
}
0 commit comments