Struct JsonSerializable<T>
Represents a bridge between JSON serialization framework in .NET and ISerializable<TSelf> interface.
Inherited Members
Namespace: DotNext.Text.Json
Assembly: DotNext.IO.dll
Syntax
public record struct JsonSerializable<T> : ISerializable<JsonSerializable<T>>, IDataTransferObject, ISupplier<T?>, IFunctional<Func<T?>>, IEquatable<JsonSerializable<T>> where T : IJsonSerializable<T>
Type Parameters
Name | Description |
---|---|
T | JSON serializable type. |
Fields
| Edit this page View SourceValue
Represents JSON serializable object.
Declaration
public required T? Value
Field Value
Type | Description |
---|---|
T |
Methods
| Edit this page View SourceDeserializeAsync<TReader>(TReader, CancellationToken)
Reads the UTF-8 encoded text representing a single JSON value. The input will be read to completion.
Declaration
public static ValueTask<T?> DeserializeAsync<TReader>(TReader reader, CancellationToken token = default) where TReader : notnull, IAsyncBinaryReader
Parameters
Type | Name | Description |
---|---|---|
TReader | reader | The input containing UTF-8 encoded text. |
CancellationToken | token | The token which may be used to cancel the read operation. |
Returns
Type | Description |
---|---|
ValueTask<T> | A value deserialized from JSON. |
Type Parameters
Name | Description |
---|---|
TReader | The type of the reader. |
ReadFromAsync<TReader>(TReader, CancellationToken)
Decodes the object of type TSelf
from its binary representation.
Declaration
public static ValueTask<JsonSerializable<T>> ReadFromAsync<TReader>(TReader reader, CancellationToken token = default) where TReader : notnull, IAsyncBinaryReader
Parameters
Type | Name | Description |
---|---|---|
TReader | reader | The reader. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<JsonSerializable<T>> | The decoded object. |
Type Parameters
Name | Description |
---|---|
TReader | The type of the reader. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
SerializeAsync<TWriter>(TWriter, T?, CancellationToken)
Writes one JSON value (including objects or arrays) to the provided writer.
Declaration
public static ValueTask SerializeAsync<TWriter>(TWriter writer, T? value, CancellationToken token) where TWriter : notnull, IAsyncBinaryWriter
Parameters
Type | Name | Description |
---|---|---|
TWriter | writer | UTF-8 output to write to. |
T | value | The value to convert. |
CancellationToken | token | The token that can be used to cancel the write operation. |
Returns
Type | Description |
---|---|
ValueTask | A task that represents the asynchronous write operation. |
Type Parameters
Name | Description |
---|---|
TWriter | The type of the writer. |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override readonly string? ToString()
Returns
Type | Description |
---|---|
string | The fully qualified type name. |
Overrides
| Edit this page View SourceTransformAsync<TInput>(TInput, CancellationToken)
Converts an object to JSON-serializable data transfer object.
Declaration
public static ValueTask<T?> TransformAsync<TInput>(TInput input, CancellationToken token = default) where TInput : notnull, IDataTransferObject
Parameters
Type | Name | Description |
---|---|---|
TInput | input | The object to transform. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<T> | Deserialized object. |
Type Parameters
Name | Description |
---|---|
TInput | The type of the object to transform. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |