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