Show / Hide Table of Contents

Struct JsonSerializable<T>

Represents a bridge between JSON serialization framework in .NET and ISerializable<TSelf> interface.

Implements
ISerializable<JsonSerializable<T>>
IDataTransferObject
ISupplier<T>
IFunctional<Func<T>>
IEquatable<JsonSerializable<T>>
Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
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 Source

Value

Represents JSON serializable object.

Declaration
public required T? Value
Field Value
Type Description
T

Methods

| Edit this page View Source

DeserializeAsync<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.

| Edit this page View Source

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 : 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.

| Edit this page View Source

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 : 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.

| Edit this page View Source

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
ValueType.ToString()
| Edit this page View Source

TransformAsync<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.

Implements

ISerializable<TSelf>
IDataTransferObject
ISupplier<TResult>
IFunctional<TDelegate>
IEquatable<T>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
DataTransferObject.ToByteArrayAsync<TObject>(TObject, MemoryAllocator<byte>?, CancellationToken)
DataTransferObject.ToMemoryAsync<TObject>(TObject, MemoryAllocator<byte>?, CancellationToken)
DataTransferObject.ToStringAsync<TObject>(TObject, Encoding, MemoryAllocator<byte>?, CancellationToken)
DataTransferObject.TransformAsync<TResult, TObject>(TObject, Func<IAsyncBinaryReader, CancellationToken, ValueTask<TResult>>, CancellationToken)
DataTransferObject.WriteToAsync<TObject>(TObject, IBufferWriter<byte>, CancellationToken)
DataTransferObject.WriteToAsync<TObject>(TObject, PipeWriter, long, CancellationToken)
DataTransferObject.WriteToAsync<TObject>(TObject, Stream, int, CancellationToken)
DataTransferObject.WriteToAsync<TObject>(TObject, Stream, Memory<byte>, CancellationToken)
ExpressionBuilder.Const<T>(T)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾