JsonSerializer.SerializeToDocument 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| SerializeToDocument(Object, JsonTypeInfo) |
將所提供的值 JsonDocument轉換為 。 |
| SerializeToDocument(Object, Type, JsonSerializerOptions) |
將所提供的值 JsonDocument轉換為 。 |
| SerializeToDocument(Object, Type, JsonSerializerContext) |
將所提供的值 JsonDocument轉換為 。 |
| SerializeToDocument<TValue>(TValue, JsonSerializerOptions) |
將所提供的值 JsonDocument轉換為 。 |
| SerializeToDocument<TValue>(TValue, JsonTypeInfo<TValue>) |
將所提供的值 JsonDocument轉換為 。 |
SerializeToDocument(Object, JsonTypeInfo)
將所提供的值 JsonDocument轉換為 。
public:
static System::Text::Json::JsonDocument ^ SerializeToDocument(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member SerializeToDocument : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> System.Text.Json.JsonDocument
Public Function SerializeToDocument (value As Object, jsonTypeInfo As JsonTypeInfo) As JsonDocument
參數
- value
- Object
要轉換的值。
- jsonTypeInfo
- JsonTypeInfo
關於要轉換的類型資料。
傳回
這是 JsonDocument 價值的表示。
例外狀況
jsonTypeInfo 是 null。
value 不符合 的 jsonTypeInfo類型。
適用於
SerializeToDocument(Object, Type, JsonSerializerOptions)
將所提供的值 JsonDocument轉換為 。
[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. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
[<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. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToDocument : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToDocument : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
static member SerializeToDocument : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
Public Function SerializeToDocument (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As JsonDocument
參數
- value
- Object
要轉換的值。
- inputType
- Type
轉換的類型 value 。
- options
- JsonSerializerOptions
控制轉換行為的選項。
傳回
這是 JsonDocument 價值的表示。
- 屬性
例外狀況
inputType 與 value不相容。
inputType 是 null。
沒有相容 JsonConverter 的 或 inputType 其可序列化的成員。
適用於
SerializeToDocument(Object, Type, JsonSerializerContext)
將所提供的值 JsonDocument轉換為 。
public:
static System::Text::Json::JsonDocument ^ SerializeToDocument(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member SerializeToDocument : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> System.Text.Json.JsonDocument
Public Function SerializeToDocument (value As Object, inputType As Type, context As JsonSerializerContext) As JsonDocument
參數
- value
- Object
要轉換的值。
- inputType
- Type
轉換的類型 value 。
- context
- JsonSerializerContext
一個可序列化型別的元資料提供者。
傳回
這是 JsonDocument 價值的表示。
例外狀況
沒有相容 JsonConverter 的 或 inputType 其可序列化的成員。
該 GetTypeInfo(Type) 類型所提供的 context 回報 null 轉換方法。
inputType 或 context 為 null。
適用於
SerializeToDocument<TValue>(TValue, JsonSerializerOptions)
將所提供的值 JsonDocument轉換為 。
[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. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonDocument SerializeToDocument<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonDocument SerializeToDocument<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static System.Text.Json.JsonDocument SerializeToDocument<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
[<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. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToDocument : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToDocument : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
static member SerializeToDocument : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
Public Function SerializeToDocument(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As JsonDocument
類型參數
- TValue
要序列化的值類型。
參數
- value
- TValue
要轉換的值。
- options
- JsonSerializerOptions
控制轉換行為的選項。
傳回
JSON 值的 JsonDocument 表示。
- 屬性
例外狀況
沒有相容 JsonConverter 的 或 TValue 其可序列化的成員。
適用於
SerializeToDocument<TValue>(TValue, JsonTypeInfo<TValue>)
將所提供的值 JsonDocument轉換為 。
public:
generic <typename TValue>
static System::Text::Json::JsonDocument ^ SerializeToDocument(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static System.Text.Json.JsonDocument SerializeToDocument<TValue>(TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member SerializeToDocument : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> System.Text.Json.JsonDocument
Public Function SerializeToDocument(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As JsonDocument
類型參數
- TValue
要序列化的值類型。
參數
- value
- TValue
要轉換的值。
- jsonTypeInfo
- JsonTypeInfo<TValue>
關於要轉換的類型資料。
傳回
這是 JsonDocument 價值的表示。
例外狀況
沒有相容 JsonConverter 的 或 TValue 其可序列化的成員。
jsonTypeInfo 是 null。