JsonSerializer.SerializeToUtf8Bytes 方法

定義

多載

SerializeToUtf8Bytes(Object, JsonTypeInfo)

將所提供的值轉換成 Byte 陣列。

SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions)

將指定型別的值轉換為 JSON 字串 (以 UTF-8 位元組編碼)。

SerializeToUtf8Bytes(Object, Type, JsonSerializerContext)

將所提供的值轉換成 Byte 陣列。

SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)

將泛型型別參數所指定型別的值轉換為 JSON 字串 (以 UTF-8 位元組編碼)。

SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>)

將所提供的值轉換成 Byte 陣列。

SerializeToUtf8Bytes(Object, JsonTypeInfo)

來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs

將所提供的值轉換成 Byte 陣列。

public:
 static cli::array <System::Byte> ^ SerializeToUtf8Bytes(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static byte[] SerializeToUtf8Bytes (object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member SerializeToUtf8Bytes : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> byte[]
Public Function SerializeToUtf8Bytes (value As Object, jsonTypeInfo As JsonTypeInfo) As Byte()

參數

value
Object

要進行轉換的值。

jsonTypeInfo
JsonTypeInfo

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

傳回

Byte[]

值的 UTF-8 表示。

例外狀況

jsonTypeInfonull

value 不符合 的類型 jsonTypeInfo

適用於

SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions)

來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs

將指定型別的值轉換為 JSON 字串 (以 UTF-8 位元組編碼)。

public static byte[] SerializeToUtf8Bytes (object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static byte[] SerializeToUtf8Bytes (object value, Type inputType, System.Text.Json.JsonSerializerOptions options = default);
static member SerializeToUtf8Bytes : obj * Type * System.Text.Json.JsonSerializerOptions -> byte[]
Public Shared Function SerializeToUtf8Bytes (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As Byte()
Public Function SerializeToUtf8Bytes (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As Byte()

參數

value
Object

要進行轉換的值。

inputType
Type

要轉換的 value 類型。

options
JsonSerializerOptions

控制轉換行為的選項。

傳回

Byte[]

值的 JSON 字串表示法 (以 UTF-8 位元組編碼)。

例外狀況

inputTypevalue 不相容。

inputTypenull

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

備註

如需詳細資訊,請參閱 如何序列化和還原序列化 JSON

適用於

SerializeToUtf8Bytes(Object, Type, JsonSerializerContext)

來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs

將所提供的值轉換成 Byte 陣列。

public:
 static cli::array <System::Byte> ^ SerializeToUtf8Bytes(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static byte[] SerializeToUtf8Bytes (object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member SerializeToUtf8Bytes : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> byte[]
Public Function SerializeToUtf8Bytes (value As Object, inputType As Type, context As JsonSerializerContext) As Byte()

參數

value
Object

要進行轉換的值。

inputType
Type

要轉換的 value 類型。

context
JsonSerializerContext

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

傳回

Byte[]

值的 UTF-8 表示。

例外狀況

inputTypevalue 不相容。

inputTypenull

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

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

適用於

SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)

來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs

將泛型型別參數所指定型別的值轉換為 JSON 字串 (以 UTF-8 位元組編碼)。

public static byte[] SerializeToUtf8Bytes<TValue> (TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static byte[] SerializeToUtf8Bytes<TValue> (TValue value, System.Text.Json.JsonSerializerOptions options = default);
static member SerializeToUtf8Bytes : 'Value * System.Text.Json.JsonSerializerOptions -> byte[]
Public Shared Function SerializeToUtf8Bytes(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As Byte()
Public Function SerializeToUtf8Bytes(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As Byte()

類型參數

TValue

值的類型。

參數

value
TValue

要進行轉換的值。

options
JsonSerializerOptions

控制轉換行為的選項。

傳回

Byte[]

值的 JSON 字串表示法 (以 UTF-8 位元組編碼)。

例外狀況

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

備註

如需詳細資訊,請參閱 如何序列化和還原序列化 JSON

適用於

SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>)

來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs
來源:
JsonSerializer.Write.ByteArray.cs

將所提供的值轉換成 Byte 陣列。

public:
generic <typename TValue>
 static cli::array <System::Byte> ^ SerializeToUtf8Bytes(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static byte[] SerializeToUtf8Bytes<TValue> (TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member SerializeToUtf8Bytes : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> byte[]
Public Function SerializeToUtf8Bytes(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As Byte()

類型參數

TValue

要序列化之值的類型。

參數

value
TValue

要進行轉換的值。

jsonTypeInfo
JsonTypeInfo<TValue>

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

傳回

Byte[]

值的 UTF-8 表示。

例外狀況

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

jsonTypeInfonull

適用於