JsonSerializer.SerializeToElement 方法

定義

多載

SerializeToElement(Object, JsonTypeInfo)

將所提供的值轉換成 JsonElement

SerializeToElement(Object, Type, JsonSerializerOptions)

將所提供的值轉換成 JsonDocument

SerializeToElement(Object, Type, JsonSerializerContext)

將所提供的值轉換成 JsonDocument

SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>)

將所提供的值轉換成 JsonDocument

SerializeToElement<TValue>(TValue, JsonSerializerOptions)

將所提供的值轉換成 JsonDocument

SerializeToElement(Object, JsonTypeInfo)

來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs

將所提供的值轉換成 JsonElement

public:
 static System::Text::Json::JsonElement SerializeToElement(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static System.Text.Json.JsonElement SerializeToElement (object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member SerializeToElement : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> System.Text.Json.JsonElement
Public Function SerializeToElement (value As Object, jsonTypeInfo As JsonTypeInfo) As JsonElement

參數

value
Object

要進行轉換的值。

jsonTypeInfo
JsonTypeInfo

要轉換之型別的相關中繼資料。

傳回

值的 JsonElement 表示。

例外狀況

jsonTypeInfonull

value 不符合 的類型 jsonTypeInfo

適用於

SerializeToElement(Object, Type, JsonSerializerOptions)

來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs

將所提供的值轉換成 JsonDocument

public static System.Text.Json.JsonElement SerializeToElement (object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
static member SerializeToElement : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
Public Function SerializeToElement (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As JsonElement

參數

value
Object

要進行轉換的值。

inputType
Type

要轉換的 value 類型。

options
JsonSerializerOptions

控制轉換行為的選項。

傳回

值的 JsonDocument 表示。

例外狀況

inputTypevalue 不相容。

inputTypenull

inputType 或其可序列化成員沒有相容的 JsonConverter

適用於

SerializeToElement(Object, Type, JsonSerializerContext)

來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs

將所提供的值轉換成 JsonDocument

public:
 static System::Text::Json::JsonElement SerializeToElement(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static System.Text.Json.JsonElement SerializeToElement (object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member SerializeToElement : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> System.Text.Json.JsonElement
Public Function SerializeToElement (value As Object, inputType As Type, context As JsonSerializerContext) As JsonElement

參數

value
Object

要進行轉換的值。

inputType
Type

要轉換的 value 類型。

context
JsonSerializerContext

可序列化類型的中繼資料提供者。

傳回

值的 JsonDocument 表示。

例外狀況

inputType 或其可序列化成員沒有相容的 JsonConverter

提供 GetTypeInfo(Type)context 之 的 方法會 null 傳回要轉換的型別。

inputTypecontextnull

適用於

SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>)

來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs

將所提供的值轉換成 JsonDocument

public:
generic <typename TValue>
 static System::Text::Json::JsonElement SerializeToElement(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static System.Text.Json.JsonElement SerializeToElement<TValue> (TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member SerializeToElement : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> System.Text.Json.JsonElement
Public Function SerializeToElement(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As JsonElement

類型參數

TValue

要序列化之值的類型。

參數

value
TValue

要進行轉換的值。

jsonTypeInfo
JsonTypeInfo<TValue>

要轉換之型別的相關中繼資料。

傳回

值的 JsonDocument 表示。

例外狀況

TValue 或其可序列化成員沒有相容的 JsonConverter

jsonTypeInfonull

適用於

SerializeToElement<TValue>(TValue, JsonSerializerOptions)

來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs
來源:
JsonSerializer.Write.Element.cs

將所提供的值轉換成 JsonDocument

public static System.Text.Json.JsonElement SerializeToElement<TValue> (TValue value, System.Text.Json.JsonSerializerOptions? options = default);
static member SerializeToElement : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
Public Function SerializeToElement(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As JsonElement

類型參數

TValue

要序列化之值的類型。

參數

value
TValue

要進行轉換的值。

options
JsonSerializerOptions

控制轉換行為的選項。

傳回

JSON 值的 JsonDocument 表示法。

例外狀況

TValue 或其可序列化成員沒有相容的 JsonConverter

適用於