Table of Contents

Class SystemTextJsonFormatter

Namespace
StreamJsonRpc
Assembly
StreamJsonRpc.dll

A formatter that emits UTF-8 encoded JSON where user data should be serializable via the JsonSerializer.

public class SystemTextJsonFormatter : FormatterBase, IJsonRpcFormatterState, IDisposable, IJsonRpcMessageTextFormatter, IJsonRpcMessageFormatter, IJsonRpcInstanceContainer, IJsonRpcMessageFactory, IJsonRpcFormatterTracingCallbacks
Inheritance
SystemTextJsonFormatter
Implements
Inherited Members

Constructors

SystemTextJsonFormatter()

Initializes a new instance of the SystemTextJsonFormatter class.

public SystemTextJsonFormatter()

Properties

Encoding

Gets or sets the encoding used for serialization for methods that do not take an explicit Encoding.

public Encoding Encoding { get; set; }

Property Value

Encoding

Never null.

Exceptions

ArgumentNullException

Thrown at an attempt to set the value to null.

JsonSerializerOptions

Gets or sets the options to use when serializing and deserializing JSON containing user data.

public JsonSerializerOptions JsonSerializerOptions { get; set; }

Property Value

JsonSerializerOptions

Methods

Deserialize(ReadOnlySequence<byte>)

Deserializes a JsonRpcMessage.

public JsonRpcMessage Deserialize(ReadOnlySequence<byte> contentBuffer)

Parameters

contentBuffer ReadOnlySequence<byte>

A sequence of bytes to deserialize.

Returns

JsonRpcMessage

The deserialized JsonRpcMessage.

Deserialize(ReadOnlySequence<byte>, Encoding)

Deserializes a sequence of bytes to a JsonRpcMessage.

public JsonRpcMessage Deserialize(ReadOnlySequence<byte> contentBuffer, Encoding encoding)

Parameters

contentBuffer ReadOnlySequence<byte>

The bytes to deserialize.

encoding Encoding

The encoding to read the bytes in contentBuffer with. Must not be null.

Returns

JsonRpcMessage

The deserialized message.

GetJsonText(JsonRpcMessage)

Gets a JSON representation for a given message for tracing purposes.

public object GetJsonText(JsonRpcMessage message)

Parameters

message JsonRpcMessage

The message to be traced.

Returns

object

Any object whose ToString() method will produce a human-readable JSON string, suitable for tracing.

Serialize(IBufferWriter<byte>, JsonRpcMessage)

Serializes a JsonRpcMessage.

public void Serialize(IBufferWriter<byte> bufferWriter, JsonRpcMessage message)

Parameters

bufferWriter IBufferWriter<byte>

The receiver of the serialized bytes.

message JsonRpcMessage

The message to serialize.