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)

将指定类型的值转换为编码为 UTF-8 字节的 JSON 字符串。Converts a value of the specified type into a JSON string, encoded as UTF-8 bytes.

SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)

将泛型类型参数指定的类型的值转换为编码为 UTF-8 字节的 JSON 字符串。Converts the value of a type specified by a generic type parameter into a JSON string, encoded as UTF-8 bytes.

适用于