Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Text.​Json.​JsonSerializer

Assembly: System.Text.Json

Inheritance: object → JsonSerializer

Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types.

Properties

public static bool
IsReflectionEnabledByDefault
Gets a value that indicates whether unconfigured <see cref="T:System.Text.Json.JsonSerializerOptions" /> instances should default to the reflection-based <see cref="T:System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver" /> .

Methods

public static object
Deserialize​(IO.​Stream utf8Json, JsonTypeInfo jsonTypeInfo)
Reads the UTF-8 encoded text representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> . The Stream will be read to completion.
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(IO.​Stream utf8Json, Type returnType, JsonSerializerOptions? options = null)
Reads the UTF-8 encoded text representing a single JSON value into a <paramref name="returnType" /> . The Stream will be read to completion.
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json JSON data to parse.
returnType The type of the object to convert to and return.
options Options to control the behavior during reading.
public static object
Deserialize​(IO.​Stream utf8Json, Type returnType, JsonSerializerContext context)
Reads the UTF-8 encoded text representing a single JSON value into a <paramref name="returnType" /> . The Stream will be read to completion.
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json JSON data to parse.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(ReadOnlySpan<​byte> utf8Json, JsonTypeInfo jsonTypeInfo)
Parses the UTF-8 encoded text representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> .
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
utf8Json JSON text to parse.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(ReadOnlySpan<​byte> utf8Json, Type returnType, JsonSerializerOptions options = null)
Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type.
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json The JSON text to parse.
returnType The type of the object to convert to and return.
options Options to control the behavior during parsing.
public static object
Deserialize​(ReadOnlySpan<​byte> utf8Json, Type returnType, JsonSerializerContext context)
Parses the UTF-8 encoded text representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json JSON text to parse.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(ReadOnlySpan<​char> json, JsonTypeInfo jsonTypeInfo)
Parses the text representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> .
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
json JSON text to parse.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(ReadOnlySpan<​char> json, Type returnType, JsonSerializerOptions options = null)
Parses the text representing a single JSON value into an instance of a specified type.
Returns A <paramref name="returnType" /> representation of the JSON value.
json The JSON text to parse.
returnType The type of the object to convert to and return.
options Options to control the behavior during parsing.
public static object
Deserialize​(ReadOnlySpan<​char> json, Type returnType, JsonSerializerContext context)
Parses the text representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
json JSON text to parse.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(string json, JsonTypeInfo jsonTypeInfo)
Parses the text representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> .
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
json JSON text to parse.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(string json, Type returnType, JsonSerializerOptions? options = null)
Parses the text representing a single JSON value into an instance of a specified type.
Returns A <paramref name="returnType" /> representation of the JSON value.
json The JSON text to parse.
returnType The type of the object to convert to and return.
options Options to control the behavior during parsing.
public static object
Deserialize​(string json, Type returnType, JsonSerializerContext context)
Parses the text representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
json JSON text to parse.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(JsonDocument document, JsonTypeInfo jsonTypeInfo)
Converts the <see cref="T:System.Text.Json.JsonDocument" /> representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> .
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
document The <see cref="T:System.Text.Json.JsonDocument" /> to convert.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(JsonDocument document, Type returnType, JsonSerializerOptions? options = null)
Converts the <see cref="T:System.Text.Json.JsonDocument" /> representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
document The <see cref="T:System.Text.Json.JsonDocument" /> to convert.
returnType The type of the object to convert to and return.
options Options to control the behavior during parsing.
public static object
Deserialize​(JsonDocument document, Type returnType, JsonSerializerContext context)
Converts the <see cref="T:System.Text.Json.JsonDocument" /> representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
document The <see cref="T:System.Text.Json.JsonDocument" /> to convert.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(JsonElement element, JsonTypeInfo jsonTypeInfo)
Converts the <see cref="T:System.Text.Json.JsonElement" /> representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> .
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
element The <see cref="T:System.Text.Json.JsonElement" /> to convert.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(JsonElement element, Type returnType, JsonSerializerOptions options = null)
Converts the <see cref="T:System.Text.Json.JsonElement" /> representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
element The <see cref="T:System.Text.Json.JsonElement" /> to convert.
returnType The type of the object to convert to and return.
options Options to control the behavior during parsing.
public static object
Deserialize​(JsonElement element, Type returnType, JsonSerializerContext context)
Converts the <see cref="T:System.Text.Json.JsonElement" /> representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
element The <see cref="T:System.Text.Json.JsonElement" /> to convert.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(JsonNode node, JsonTypeInfo jsonTypeInfo)
Converts the <see cref="T:System.Text.Json.Nodes.JsonNode" /> representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> .
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
node The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to convert.
jsonTypeInfo Metadata about the type to convert.
public static object
Deserialize​(JsonNode node, Type returnType, JsonSerializerOptions options = null)
Converts the <see cref="T:System.Text.Json.Nodes.JsonNode" /> representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
node The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to convert.
returnType The type of the object to convert to and return.
options Options to control the behavior during parsing.
public static object
Deserialize​(JsonNode? node, Type returnType, JsonSerializerContext context)
Converts the <see cref="T:System.Text.Json.Nodes.JsonNode" /> representing a single JSON value into a <paramref name="returnType" /> .
Returns A <paramref name="returnType" /> representation of the JSON value.
node The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to convert.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
public static object
Deserialize​(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
public static object
Deserialize​(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options = null)
public static object
Deserialize​(Utf8JsonReader& reader, Type returnType, JsonSerializerContext context)
public static Threading.​Tasks.​ValueTask<​object>
DeserializeAsync​(IO.​Pipelines.​PipeReader utf8Json, JsonTypeInfo jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
<para>Reads the UTF-8 encoded text representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" />.</para> <para>The PipeReader will be read to completion.</para>
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​object>
DeserializeAsync​(IO.​Pipelines.​PipeReader utf8Json, Type returnType, JsonSerializerOptions? options = null, Threading.​CancellationToken cancellationToken = null)
<para>Reads the UTF-8 encoded text representing a single JSON value into a <paramref name="returnType" />.</para> <para>The PipeReader will be read to completion.</para>
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json JSON data to parse.
returnType The type of the object to convert to and return.
options Options to control the behavior during reading.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​object>
DeserializeAsync​(IO.​Pipelines.​PipeReader utf8Json, Type returnType, JsonSerializerContext context, Threading.​CancellationToken cancellationToken = null)
<para>Reads the UTF-8 encoded text representing a single JSON value into a <paramref name="returnType" />.</para> <para>The PipeReader will be read to completion.</para>
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json JSON data to parse.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​object>
DeserializeAsync​(IO.​Stream utf8Json, JsonTypeInfo jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Reads the UTF-8 encoded text representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo" /> . The Stream will be read to completion.
Returns A <paramref name="jsonTypeInfo" /> representation of the JSON value.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​object>
DeserializeAsync​(IO.​Stream utf8Json, Type returnType, JsonSerializerOptions? options = null, Threading.​CancellationToken cancellationToken = null)
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.
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json The JSON data to parse.
returnType The type of the object to convert to and return.
options Options to control the behavior during reading.
cancellationToken A cancellation token that may be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​object>
DeserializeAsync​(IO.​Stream utf8Json, Type returnType, JsonSerializerContext context, Threading.​CancellationToken cancellationToken = null)
Reads the UTF-8 encoded text representing a single JSON value into a <paramref name="returnType" /> . The Stream will be read to completion.
Returns A <paramref name="returnType" /> representation of the JSON value.
utf8Json JSON data to parse.
returnType The type of the object to convert to and return.
context A metadata provider for serializable types.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Pipelines.​PipeReader utf8Json, bool topLevelValues, JsonSerializerOptions options = null, Threading.​CancellationToken cancellationToken = null)
<para>Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize sequences of JSON values in a streaming manner.</para>
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON sequence.
utf8Json JSON data to parse.
topLevelValues <see langword="true" /> to deserialize from a sequence of top-level JSON values, or <see langword="false" /> to deserialize from a single top-level array.
options Options to control the behavior during reading.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Pipelines.​PipeReader utf8Json, JsonSerializerOptions options = null, Threading.​CancellationToken cancellationToken = null)
<para>Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize root-level JSON arrays in a streaming manner.</para>
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON array.
utf8Json JSON data to parse.
options Options to control the behavior during reading.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Pipelines.​PipeReader utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo, bool topLevelValues, Threading.​CancellationToken cancellationToken = null)
<para>Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize sequences of JSON values in a streaming manner.</para>
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON sequence.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the element type to convert.
topLevelValues Whether to deserialize from a sequence of top-level JSON values.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Pipelines.​PipeReader utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
<para>Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize root-level JSON arrays in a streaming manner.</para>
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON array.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the element type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Stream utf8Json, bool topLevelValues, JsonSerializerOptions options = null, Threading.​CancellationToken cancellationToken = null)
<para>Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize sequences of JSON values in a streaming manner.</para>
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON sequence.
utf8Json JSON data to parse.
topLevelValues <see langword="true" /> to deserialize from a sequence of top-level JSON values, or <see langword="false" /> to deserialize from a single top-level array.
options Options to control the behavior during reading.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Stream utf8Json, JsonSerializerOptions options = null, Threading.​CancellationToken cancellationToken = null)
Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize root-level JSON arrays in a streaming manner.
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON array.
utf8Json JSON data to parse.
options Options to control the behavior during reading.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Stream utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo, bool topLevelValues, Threading.​CancellationToken cancellationToken = null)
<para>Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize sequences of JSON values in a streaming manner.</para>
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON sequence.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the element type to convert.
topLevelValues Whether to deserialize from a sequence of top-level JSON values.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
DeserializeAsyncEnumerable​(IO.​Stream utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Wraps the UTF-8 encoded text into an <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> that can be used to deserialize root-level JSON arrays in a streaming manner.
Returns An <see cref="T:System.Collections.Generic.IAsyncEnumerable`1" /> representation of the provided JSON array.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the element type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​TValue>
DeserializeAsync​(IO.​Pipelines.​PipeReader utf8Json, JsonSerializerOptions options = null, Threading.​CancellationToken cancellationToken = null)
<para>Reads the UTF-8 encoded text representing a single JSON value into a <typeparamref name="TValue" />.</para> <para>The PipeReader will be read to completion.</para>
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json JSON data to parse.
options Options to control the behavior during reading.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​TValue>
DeserializeAsync​(IO.​Pipelines.​PipeReader utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
<para>Reads the UTF-8 encoded text representing a single JSON value into a <typeparamref name="TValue" />.</para> <para>The PipeReader will be read to completion.</para>
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​TValue>
DeserializeAsync​(IO.​Stream utf8Json, JsonSerializerOptions options = null, Threading.​CancellationToken cancellationToken = null)
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.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json The JSON data to parse.
options Options to control the behavior during reading.
cancellationToken A token that may be used to cancel the read operation.
public static Threading.​Tasks.​ValueTask<​TValue>
DeserializeAsync​(IO.​Stream utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Reads the UTF-8 encoded text representing a single JSON value into a <typeparamref name="TValue" /> . The Stream will be read to completion.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the read operation.
public static TValue
Deserialize​(IO.​Stream utf8Json, JsonSerializerOptions options = null)
Reads the UTF-8 encoded text representing a single JSON value into a <typeparamref name="TValue" /> . The Stream will be read to completion.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json JSON data to parse.
options Options to control the behavior during reading.
public static TValue
Deserialize​(IO.​Stream utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo)
Reads the UTF-8 encoded text representing a single JSON value into a <typeparamref name="TValue" /> . The Stream will be read to completion.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json JSON data to parse.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(ReadOnlySpan<​byte> utf8Json, JsonSerializerOptions options = null)
Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json The JSON text to parse.
options Options to control the behavior during parsing.
public static TValue
Deserialize​(ReadOnlySpan<​byte> utf8Json, JsonTypeInfo<​TValue> jsonTypeInfo)
Parses the UTF-8 encoded text representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
utf8Json JSON text to parse.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(ReadOnlySpan<​char> json, JsonSerializerOptions options = null)
Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
json The JSON text to parse.
options Options to control the behavior during parsing.
public static TValue
Deserialize​(ReadOnlySpan<​char> json, JsonTypeInfo<​TValue> jsonTypeInfo)
Parses the text representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
json JSON text to parse.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(string json, JsonSerializerOptions options = null)
Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.
Returns A <typeparamref name="TValue" /> representation of the JSON value.
json The JSON text to parse.
options Options to control the behavior during parsing.
public static TValue
Deserialize​(string json, JsonTypeInfo<​TValue> jsonTypeInfo)
Parses the text representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
json JSON text to parse.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(JsonDocument document, JsonSerializerOptions options = null)
Converts the <see cref="T:System.Text.Json.JsonDocument" /> representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
document The <see cref="T:System.Text.Json.JsonDocument" /> to convert.
options Options to control the behavior during parsing.
public static TValue
Deserialize​(JsonDocument document, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the <see cref="T:System.Text.Json.JsonDocument" /> representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
document The <see cref="T:System.Text.Json.JsonDocument" /> to convert.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(JsonElement element, JsonSerializerOptions options = null)
Converts the <see cref="T:System.Text.Json.JsonElement" /> representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
element The <see cref="T:System.Text.Json.JsonElement" /> to convert.
options Options to control the behavior during parsing.
public static TValue
Deserialize​(JsonElement element, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the <see cref="T:System.Text.Json.JsonElement" /> representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
element The <see cref="T:System.Text.Json.JsonElement" /> to convert.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(JsonNode node, JsonSerializerOptions options = null)
Converts the <see cref="T:System.Text.Json.Nodes.JsonNode" /> representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
node The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to convert.
options Options to control the behavior during parsing.
public static TValue
Deserialize​(JsonNode node, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the <see cref="T:System.Text.Json.Nodes.JsonNode" /> representing a single JSON value into a <typeparamref name="TValue" /> .
Returns A <typeparamref name="TValue" /> representation of the JSON value.
node The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to convert.
jsonTypeInfo Metadata about the type to convert.
public static TValue
Deserialize​(Utf8JsonReader& reader, JsonSerializerOptions options = null)
public static TValue
Deserialize​(Utf8JsonReader& reader, JsonTypeInfo<​TValue> jsonTypeInfo)
public static void
Serialize​(IO.​Stream utf8Json, object value, JsonTypeInfo jsonTypeInfo)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static void
Serialize​(IO.​Stream utf8Json, object value, Type inputType, JsonSerializerOptions? options = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
public static void
Serialize​(IO.​Stream utf8Json, object value, Type inputType, JsonSerializerContext context)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
public static string
Serialize​(object value, JsonTypeInfo jsonTypeInfo)
Converts the provided value into a <see cref="T:System.String" /> .
Returns A <see cref="T:System.String" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static string
Serialize​(object value, Type inputType, JsonSerializerOptions? options = null)
Converts the value of a specified type into a JSON string.
Returns The JSON string representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
public static string
Serialize​(object value, Type inputType, JsonSerializerContext context)
Converts the provided value into a <see cref="T:System.String" /> .
Returns A <see cref="T:System.String" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
public static void
Serialize​(Utf8JsonWriter writer, object value, JsonTypeInfo jsonTypeInfo)
Writes one JSON value (including objects or arrays) to the provided writer.
writer The writer to write.
value The value to convert and write.
jsonTypeInfo Metadata about the type to convert.
public static void
Serialize​(Utf8JsonWriter writer, object value, Type inputType, JsonSerializerOptions? options = null)
Writes the JSON representation of the specified type to the provided writer.
writer The JSON writer to write to.
value The value to convert and write.
inputType The type of the <paramref name="value" /> to convert.
options Options to control serialization behavior.
public static void
Serialize​(Utf8JsonWriter writer, object value, Type inputType, JsonSerializerContext context)
Writes one JSON value (including objects or arrays) to the provided writer.
writer A JSON writer to write to.
value The value to convert and write.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
SerializeAsync​(IO.​Stream utf8Json, object value, JsonTypeInfo jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and writes it to the <see cref="T:System.IO.Stream" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Stream utf8Json, object value, Type inputType, JsonSerializerOptions? options = null, Threading.​CancellationToken cancellationToken = null)
Asynchronously converts the value of a specified type to UTF-8 encoded JSON text and writes it to the specified stream.
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 stream to write to.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control serialization behavior.
cancellationToken A token that may be used to cancel the write operation.
SerializeAsync​(IO.​Stream utf8Json, object value, Type inputType, JsonSerializerContext context, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Pipelines.​PipeWriter utf8Json, TValue value, JsonSerializerOptions? options = null, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Pipelines.PipeWriter" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Pipelines.PipeWriter" /> to write to.
value The value to convert.
options Options to control the conversion behavior.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Stream utf8Json, TValue value, JsonSerializerOptions? options = null, Threading.​CancellationToken cancellationToken = null)
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.
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 stream to write to.
value The value to convert.
options Options to control serialization behavior.
cancellationToken A token that may be used to cancel the write operation.
SerializeAsync​(IO.​Stream utf8Json, TValue value, JsonTypeInfo<​TValue> jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Pipelines.​PipeWriter utf8Json, TValue value, JsonTypeInfo<​TValue> jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Pipelines.PipeWriter" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Pipelines.PipeWriter" /> to write to.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Pipelines.​PipeWriter utf8Json, object value, JsonTypeInfo jsonTypeInfo, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Pipelines.PipeWriter" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Pipelines.PipeWriter" /> to write to.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Pipelines.​PipeWriter utf8Json, object value, Type inputType, JsonSerializerOptions? options = null, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Pipelines.PipeWriter" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Pipelines.PipeWriter" /> to write to.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
SerializeAsync​(IO.​Pipelines.​PipeWriter utf8Json, object value, Type inputType, JsonSerializerContext context, Threading.​CancellationToken cancellationToken = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Pipelines.PipeWriter" /> .
Returns A task that represents the asynchronous write operation.
utf8Json The UTF-8 <see cref="T:System.IO.Pipelines.PipeWriter" /> to write to.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the write operation.
public static JsonDocument
SerializeToDocument​(object value, JsonTypeInfo jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Text.Json.JsonDocument" /> .
Returns A <see cref="T:System.Text.Json.JsonDocument" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static JsonDocument
SerializeToDocument​(object value, Type inputType, JsonSerializerOptions? options = null)
Converts the provided value into a <see cref="T:System.Text.Json.JsonDocument" /> .
Returns A <see cref="T:System.Text.Json.JsonDocument" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
public static JsonDocument
SerializeToDocument​(object value, Type inputType, JsonSerializerContext context)
Converts the provided value into a <see cref="T:System.Text.Json.JsonDocument" /> .
Returns A <see cref="T:System.Text.Json.JsonDocument" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
public static JsonDocument
SerializeToDocument​(TValue value, JsonSerializerOptions? options = null)
Converts the provided value into a <see cref="T:System.Text.Json.JsonDocument" /> .
Returns A <see cref="T:System.Text.Json.JsonDocument" /> representation of the JSON value.
value The value to convert.
options Options to control the conversion behavior.
public static JsonDocument
SerializeToDocument​(TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Text.Json.JsonDocument" /> .
Returns A <see cref="T:System.Text.Json.JsonDocument" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static JsonElement
SerializeToElement​(object value, JsonTypeInfo jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Text.Json.JsonElement" /> .
Returns A <see cref="T:System.Text.Json.JsonElement" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static JsonElement
SerializeToElement​(object value, Type inputType, JsonSerializerOptions options = null)
Converts the provided value into a <see cref="T:System.Text.Json.JsonElement" /> .
Returns A <see cref="T:System.Text.Json.JsonElement" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
public static JsonElement
SerializeToElement​(object value, Type inputType, JsonSerializerContext context)
Converts the provided value into a <see cref="T:System.Text.Json.JsonElement" /> .
Returns A <see cref="T:System.Text.Json.JsonElement" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
public static JsonElement
SerializeToElement​(TValue value, JsonSerializerOptions options = null)
Converts the provided value into a <see cref="T:System.Text.Json.JsonElement" /> .
Returns A <see cref="T:System.Text.Json.JsonElement" /> representation of the JSON value.
value The value to convert.
options Options to control the conversion behavior.
public static JsonElement
SerializeToElement​(TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Text.Json.JsonElement" /> .
Returns A <see cref="T:System.Text.Json.JsonElement" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static JsonNode
SerializeToNode​(object value, JsonTypeInfo jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
Returns A <see cref="T:System.Text.Json.Nodes.JsonNode" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static JsonNode
SerializeToNode​(object value, Type inputType, JsonSerializerOptions options = null)
Converts the provided value into a <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
Returns A <see cref="T:System.Text.Json.Nodes.JsonNode" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
public static JsonNode
SerializeToNode​(object value, Type inputType, JsonSerializerContext context)
Converts the provided value into a <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
Returns A <see cref="T:System.Text.Json.Nodes.JsonNode" /> representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
public static JsonNode
SerializeToNode​(TValue value, JsonSerializerOptions options = null)
Converts the provided value into a <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
Returns A <see cref="T:System.Text.Json.Nodes.JsonNode" /> representation of the JSON value.
value The value to convert.
options Options to control the conversion behavior.
public static JsonNode
SerializeToNode​(TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
Returns A <see cref="T:System.Text.Json.Nodes.JsonNode" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static byte[]
SerializeToUtf8Bytes​(object value, JsonTypeInfo jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Byte" /> array.
Returns A UTF-8 representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static byte[]
SerializeToUtf8Bytes​(object value, Type inputType, JsonSerializerOptions? options = null)
Converts a value of the specified type into a JSON string, encoded as UTF-8 bytes.
Returns A JSON string representation of the value, encoded as UTF-8 bytes.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
options Options to control the conversion behavior.
public static byte[]
SerializeToUtf8Bytes​(object value, Type inputType, JsonSerializerContext context)
Converts the provided value into a <see cref="T:System.Byte" /> array.
Returns A UTF-8 representation of the value.
value The value to convert.
inputType The type of the <paramref name="value" /> to convert.
context A metadata provider for serializable types.
public static byte[]
SerializeToUtf8Bytes​(TValue value, JsonSerializerOptions? options = null)
Converts the value of a type specified by a generic type parameter into a JSON string, encoded as UTF-8 bytes.
Returns A JSON string representation of the value, encoded as UTF-8 bytes.
value The value to convert.
options Options to control the conversion behavior.
public static byte[]
SerializeToUtf8Bytes​(TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the provided value into a <see cref="T:System.Byte" /> array.
Returns A UTF-8 representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static void
Serialize​(IO.​Stream utf8Json, TValue value, JsonSerializerOptions? options = null)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
options Options to control the conversion behavior.
public static void
Serialize​(IO.​Stream utf8Json, TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the provided value to UTF-8 encoded JSON text and write it to the <see cref="T:System.IO.Stream" /> .
utf8Json The UTF-8 <see cref="T:System.IO.Stream" /> to write to.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public static void
Serialize​(Utf8JsonWriter writer, TValue value, JsonSerializerOptions? options = null)
Writes the JSON representation of a type specified by a generic type parameter to the provided writer.
writer A JSON writer to write to.
value The value to convert and write.
options Options to control serialization behavior.
public static void
Serialize​(Utf8JsonWriter writer, TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Writes one JSON value (including objects or arrays) to the provided writer.
writer The writer to write.
value The value to convert and write.
jsonTypeInfo Metadata about the type to convert.
public static string
Serialize​(TValue value, JsonSerializerOptions? options = null)
Converts the value of a type specified by a generic type parameter into a JSON string.
Returns A JSON string representation of the value.
value The value to convert.
options Options to control serialization behavior.
public static string
Serialize​(TValue value, JsonTypeInfo<​TValue> jsonTypeInfo)
Converts the provided value into a <see cref="T:System.String" /> .
Returns A <see cref="T:System.String" /> representation of the value.
value The value to convert.
jsonTypeInfo Metadata about the type to convert.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object