Table of Contents

Class JsonSchemaSerializer<T>

Namespace
Solace.SchemaRegistry.Serdes.JsonSchema
Assembly
Solace.SchemaRegistry.Serdes.JsonSchema.dll

A JSON Schema serializer that converts objects of type T into byte arrays with JSON Schema validation. Configuration properties can be found in JsonSchemaProperties.

public class JsonSchemaSerializer<T> : AbstractSerializer<JsonSchemaModel, T>, IAsyncSerializer<T>, IDisposable

Type Parameters

T

The type of object to be serialized. Should be serializable to JSON.

Inheritance
JsonSchemaSerializer<T>
Implements
IAsyncSerializer<T>
Inherited Members

Remarks

JsonSchemaSerializer<T> requires schema resolution through headers for proper operation. Schema ID must be available during serialization to resolve and apply the appropriate schema.

Note: This serializer establishes connections that may prevent application exit. Always call Dispose() when finished to properly clean up resources.

Methods

Configure(IDictionary<string, object>)

Configures this serializer with the specified properties.

public override void Configure(IDictionary<string, object> properties)

Parameters

properties IDictionary<string, object>

A dictionary containing configuration properties for the serializer

Exceptions

ArgumentException

Thrown when required configuration properties are missing or invalid

SerializePayload(IRecord<T>, ISchemaLookupResult<JsonSchemaModel>, Stream, CancellationToken)

Serializes the payload data using the resolved JSON schema with optional validation.

protected override ValueTask SerializePayload(IRecord<T> record, ISchemaLookupResult<JsonSchemaModel> schemaLookup, Stream outputStream, CancellationToken token)

Parameters

record IRecord<T>

The record containing the data to serialize

schemaLookup ISchemaLookupResult<JsonSchemaModel>

The resolved schema lookup result containing the JSON schema

outputStream Stream

The output stream to write the serialized data to

token CancellationToken

Cancellation token for the operation

Returns

ValueTask

A task representing the asynchronous serialization operation

Exceptions

JsonSchemaValidationException

Thrown when JSON schema validation fails

SerializationException

Thrown when serialization fails

OperationCanceledException

Thrown when the operation is canceled via the cancellation token

See Also