Struct JsonSerializable<T>
Represents a bridge between JSON serialization framework in .NET and ISerializable<TSelf> interface.
Implements
Inherited Members
Namespace: DotNext.Text.Json
Assembly: DotNext.IO.dll
Syntax
public struct JsonSerializable<T> : ISerializable<JsonSerializable<T>>, IDataTransferObject, ISupplier<T?>, IFunctional, IEquatable<JsonSerializable<T>> where T : IJsonSerializable<T>
Type Parameters
| Name | Description |
|---|---|
| T | JSON serializable type. |
Fields
View SourceValue
Represents JSON serializable object.
Declaration
public required T? Value
Field Value
| Type | Description |
|---|---|
| T |
Methods
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 : 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. |
Equals(JsonSerializable<T>)
Declaration
public readonly bool Equals(JsonSerializable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonSerializable<T> | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Declaration
public override readonly bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
View SourceGetHashCode()
Declaration
public override readonly int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
View SourceSerializeAsync<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 : 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()
Declaration
public override readonly string? ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
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 : 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. |
Operators
View Sourceoperator ==(JsonSerializable<T>, JsonSerializable<T>)
Declaration
public static bool operator ==(JsonSerializable<T> left, JsonSerializable<T> right)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonSerializable<T> | left | |
| JsonSerializable<T> | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(JsonSerializable<T>, JsonSerializable<T>)
Declaration
public static bool operator !=(JsonSerializable<T> left, JsonSerializable<T> right)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonSerializable<T> | left | |
| JsonSerializable<T> | right |
Returns
| Type | Description |
|---|---|
| bool |
Explicit Interface Implementations
View SourceReadFromAsync<TReader>(TReader, CancellationToken)
Decodes the object of type TSelf from its binary representation.
Declaration
static ValueTask<JsonSerializable<T>> ReadFromAsync<TReader>(TReader reader, CancellationToken token = default) where TReader : 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. |