JsonSerializerOptions.TryGetTypeInfo(Type, JsonTypeInfo) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Tries to get the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.
public:
bool TryGetTypeInfo(Type ^ type, [Runtime::InteropServices::Out] System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ % typeInfo);
public bool TryGetTypeInfo(Type type, out System.Text.Json.Serialization.Metadata.JsonTypeInfo? typeInfo);
member this.TryGetTypeInfo : Type * JsonTypeInfo -> bool
Public Function TryGetTypeInfo (type As Type, ByRef typeInfo As JsonTypeInfo) As Boolean
- type
- Type
The type to resolve contract metadata for.
- typeInfo
- JsonTypeInfo
When this method returns, contains the resolved contract metadata, or null
if the contract could not be resolved.
true
if a contract for type
was found, or false
otherwise.
type
is null
.
type
is not valid for serialization.
Returned metadata can be downcast to JsonTypeInfo<T> and used with the relevant JsonSerializer overloads.
If the JsonSerializerOptions instance is locked for modification, the method will return a cached instance for the metadata.
Produkt | Versioner |
---|---|
.NET | 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10 |
.NET Standard | 2.0 (package-provided) |
Feedback om .NET
.NET är ett öppen källkod projekt. Välj en länk för att ge feedback: