JsonSerializer 類別

定義

提供功能將物件或實值型別序列化為 JSON,並將 JSON 還原序列化為物件或實值型別。Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types.

public ref class JsonSerializer abstract sealed
public static class JsonSerializer
type JsonSerializer = class
Public Class JsonSerializer
繼承
JsonSerializer

備註

如需詳細資訊,請參閱 如何序列化和還原序列化 JSONFor more information, see How to serialize and deserialize JSON.

方法

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions)

將表示單一 JSON 值的 UTF-8 編碼文字,剖析為指定類型的執行個體。Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type.

Deserialize(String, Type, JsonSerializerOptions)

將表示單一 JSON 值的文字,剖析為指定類型的執行個體。Parses the text representing a single JSON value into an instance of a specified type.

Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)

從提供的讀取器讀取一個 JSON 值 (包括物件或陣列),並將其轉換為指定類型的執行個體。Reads one JSON value (including objects or arrays) from the provided reader and converts it into an instance of a specified type.

Deserialize<TValue>(ReadOnlySpan<Byte>, JsonSerializerOptions)

將表示單一 JSON 值的 UTF-8 編碼文字,剖析成泛型型別參數所指定類型的執行個體。Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter.

Deserialize<TValue>(String, JsonSerializerOptions)

將表示單一 JSON 值的文字,剖析成泛型型別參數所指定類型的執行個體。Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.

Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)

從提供的讀取器,將一個 JSON 值 (包括物件或陣列) 讀取至泛型型別參數所指定類型的執行個體。Reads one JSON value (including objects or arrays) from the provided reader into an instance of the type specified by a generic type parameter.

DeserializeAsync(Stream, Type, JsonSerializerOptions, CancellationToken)

將代表單一 JSON 值的 UTF-8 編碼文字,以非同步方式讀取到指定類型的執行個體中。Asynchronously reads the UTF-8 encoded text representing a single JSON value into an instance of a specified type. 資料流將會讀取至完成。The stream will be read to completion.

DeserializeAsync<TValue>(Stream, JsonSerializerOptions, CancellationToken)

將表示單一 JSON 值的 UTF-8 編碼文字,以非同步方式讀取到泛型型別參數所指定類型的執行個體中。Asynchronously reads the UTF-8 encoded text representing a single JSON value into an instance of a type specified by a generic type parameter. 資料流將會讀取至完成。The stream will be read to completion.

Serialize(Object, Type, JsonSerializerOptions)

將指定型別的值轉換為 JSON 字串。Converts the value of a specified type into a JSON string.

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)

將指定型別的 JSON 表示法寫入至提供的寫入器。Writes the JSON representation of the specified type to the provided writer.

Serialize<TValue>(TValue, JsonSerializerOptions)

將泛型型別參數所指定型別的值轉換為 JSON 字串。Converts the value of a type specified by a generic type parameter into a JSON string.

Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)

將泛型型別參數所指定型別的 JSON 表示法寫入至提供的寫入器。Writes the JSON representation of a type specified by a generic type parameter to the provided writer.

SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken)

將指定類型的值,以非同步方式轉換成 UTF-8 編碼的 JSON 文字,並將其寫入指定的資料流。Asynchronously converts the value of a specified type to UTF-8 encoded JSON text and writes it to the specified stream.

SerializeAsync<TValue>(Stream, TValue, JsonSerializerOptions, CancellationToken)

將泛型型別參數所指定類型的值,以非同步方式轉換為 UTF-8 編碼的 JSON 文字,並將它寫入資料流。Asynchronously converts a value of a type specified by a generic type parameter to UTF-8 encoded JSON text and writes it to a stream.

SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions)

將指定型別的值轉換為 JSON 字串 (以 UTF-8 位元組編碼)。Converts a value of the specified type into a JSON string, encoded as UTF-8 bytes.

SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)

將泛型型別參數所指定型別的值轉換為 JSON 字串 (以 UTF-8 位元組編碼)。Converts the value of a type specified by a generic type parameter into a JSON string, encoded as UTF-8 bytes.

適用於