Table of Contents

Class JsonHelper

Namespace
DuetAPI.Utility
Assembly
DuetAPI.dll

Helper class for JSON serialization, deserialization, patch creation and patch application

public static class JsonHelper
Inheritance
JsonHelper
Inherited Members

Fields

DefaultJsonOptions

Default JSON (de-)serialization options

public static readonly JsonSerializerOptions DefaultJsonOptions

Field Value

JsonSerializerOptions

NoNullJsonOptions

JSON (de-)serialization options that omit null values

public static readonly JsonSerializerOptions NoNullJsonOptions

Field Value

JsonSerializerOptions

Methods

ReceiveUtf8Json(Socket)

Receive a serialized JSON object from a socket in UTF-8 format

public static MemoryStream ReceiveUtf8Json(Socket socket)

Parameters

socket Socket

Socket to read from

Returns

MemoryStream

Plain JSON

Exceptions

SocketException

Connection has been closed

ReceiveUtf8JsonAsync(Socket, CancellationToken)

Receive a serialized JSON object from a socket in UTF-8 format asynchronously

public static ValueTask<MemoryStream> ReceiveUtf8JsonAsync(Socket socket, CancellationToken cancellationToken = default)

Parameters

socket Socket

Socket to read from

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask<MemoryStream>

Plain JSON

Exceptions

OperationCanceledException

Operation has been cancelled

SocketException

Connection has been closed