Show / Hide Table of Contents

    Class JsonMessageSerializer

    Serializes the messages as JSON.

    Inheritance
    object
    JsonMessageSerializer
    Implements
    IMessageSerializer
    IEquatable<JsonMessageSerializer>
    Inherited Members
    object.GetType()
    object.ToString()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: Silverback.Messaging.Serialization
    Assembly: Silverback.Integration.dll
    Syntax
    public sealed class JsonMessageSerializer : IMessageSerializer, IEquatable<JsonMessageSerializer>

    Constructors

    JsonMessageSerializer(JsonSerializerOptions?, bool?)

    Initializes a new instance of the JsonMessageSerializer class.

    Declaration
    public JsonMessageSerializer(JsonSerializerOptions? options = null, bool? mustSetTypeHeader = null)
    Parameters
    Type Name Description
    JsonSerializerOptions options

    The JsonSerializer options.

    bool? mustSetTypeHeader

    A value indicating whether the message type header (see MessageType) must be set.

    Properties

    MustSetTypeHeader

    Gets a value indicating whether the message type header (see MessageType) must be set. This is necessary when sending multiple message type through the same endpoint, to allow Silverback to automatically figure out the correct type to deserialize into.

    Declaration
    public bool MustSetTypeHeader { get; }
    Property Value
    Type Description
    bool

    Options

    Gets the JsonSerializer options.

    Declaration
    public JsonSerializerOptions? Options { get; }
    Property Value
    Type Description
    JsonSerializerOptions

    Methods

    Equals(JsonMessageSerializer?)

    Serializes the messages as JSON.

    Declaration
    public bool Equals(JsonMessageSerializer? other)
    Parameters
    Type Name Description
    JsonMessageSerializer other
    Returns
    Type Description
    bool

    Equals(object?)

    Serializes the messages as JSON.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)

    GetHashCode()

    Serializes the messages as JSON.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()

    SerializeAsync(object?, MessageHeaderCollection, ProducerEndpoint)

    Serializes the specified message object into a byte array.

    Declaration
    public ValueTask<Stream?> SerializeAsync(object? message, MessageHeaderCollection headers, ProducerEndpoint endpoint)
    Parameters
    Type Name Description
    object message

    The message object to be serialized.

    MessageHeaderCollection headers

    The message headers collection.

    ProducerEndpoint endpoint

    The endpoint.

    Returns
    Type Description
    ValueTask<Stream>

    A Task<TResult> representing the asynchronous operation. The task result contains the Stream with the serialized message.

    Implements

    IMessageSerializer
    IEquatable<T>
    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini