JsonTypeInfo.CreateJsonTypeInfo 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| CreateJsonTypeInfo(Type, JsonSerializerOptions) |
會產生一個空白 JsonTypeInfo 實例。 |
| CreateJsonTypeInfo<T>(JsonSerializerOptions) |
會產生一個空白 JsonTypeInfo<T> 實例。 |
CreateJsonTypeInfo(Type, JsonSerializerOptions)
會產生一個空白 JsonTypeInfo 實例。
public:
static System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ CreateJsonTypeInfo(Type ^ type, System::Text::Json::JsonSerializerOptions ^ options);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
public static System.Text.Json.Serialization.Metadata.JsonTypeInfo CreateJsonTypeInfo(Type type, System.Text.Json.JsonSerializerOptions options);
public static System.Text.Json.Serialization.Metadata.JsonTypeInfo CreateJsonTypeInfo(Type type, System.Text.Json.JsonSerializerOptions options);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
static member CreateJsonTypeInfo : Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.Serialization.Metadata.JsonTypeInfo
static member CreateJsonTypeInfo : Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.Serialization.Metadata.JsonTypeInfo
Public Shared Function CreateJsonTypeInfo (type As Type, options As JsonSerializerOptions) As JsonTypeInfo
參數
- type
- Type
合約元資料所指定的類型。
- options
- JsonSerializerOptions
該 JsonSerializerOptions 元資料所關聯的實例。
傳回
一個空白 JsonTypeInfo 的實例。
- 屬性
例外狀況
type 或 options 為 null。
type 無法用於序列化。
備註
回傳 JsonTypeInfo 的結果將為空白,唯獨 Converter 屬性將由該類型內建轉換器解析 Converters 。 類型宣告中指定的 via JsonConverterAttribute 的轉換器不會被此方法解析。
被解析的轉換器會影響 的 Kind值,限制了在實 JsonTypeInfo 例中可修改的元資料類型。
適用於
CreateJsonTypeInfo<T>(JsonSerializerOptions)
會產生一個空白 JsonTypeInfo<T> 實例。
public:
generic <typename T>
static System::Text::Json::Serialization::Metadata::JsonTypeInfo<T> ^ CreateJsonTypeInfo(System::Text::Json::JsonSerializerOptions ^ options);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
public static System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> CreateJsonTypeInfo<T>(System.Text.Json.JsonSerializerOptions options);
public static System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> CreateJsonTypeInfo<T>(System.Text.Json.JsonSerializerOptions options);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
static member CreateJsonTypeInfo : System.Text.Json.JsonSerializerOptions -> System.Text.Json.Serialization.Metadata.JsonTypeInfo<'T>
static member CreateJsonTypeInfo : System.Text.Json.JsonSerializerOptions -> System.Text.Json.Serialization.Metadata.JsonTypeInfo<'T>
Public Shared Function CreateJsonTypeInfo(Of T) (options As JsonSerializerOptions) As JsonTypeInfo(Of T)
類型參數
- T
合約元資料所指定的類型。
參數
- options
- JsonSerializerOptions
該 JsonSerializerOptions 元資料所關聯的實例。
傳回
一個空白 JsonTypeInfo<T> 的實例。
- 屬性
例外狀況
options 是 null。
備註
回傳 <的 see cref=“T:System.Text.Json.Serialization.Metadata.JsonTypeInfo'1> 將為空白,唯 Converter 獨該屬性會由該型別的內建轉換器解析 Converters 。 類型宣告中指定的 via JsonConverterAttribute 的轉換器不會被此方法解析。
被解析的轉換器會影響 的 Kind值,限制了在實 JsonTypeInfo 例中可修改的元資料類型。