AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/nservicebus/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

System.Text.Json serializer

NuGet Package:
NServiceBus 10.x

The System.Text.Json message serializer uses the built-in JSON serialization in .NET to serialize and deserialize messages. This serializer should be the default choice for serialization in new projects.

Usage

endpointConfiguration.UseSerialization<SystemJsonSerializer>();

Specifying content type

The default content type is application/json. It can be changed using:

endpointConfiguration.UseSerialization<SystemJsonSerializer>()
    .ContentType("application/json; systemjson");

Customizing serialization options

To control how serialization and deserialization are performed, pass in JsonSerializerOptions:

var jsonSerializerOptions = new JsonSerializerOptions
{
    WriteIndented = true
};

endpointConfiguration.UseSerialization<SystemJsonSerializer>()
    .Options(jsonSerializerOptions);

Trimming and Native AOT

Registering message types with a source-generated JsonSerializerContext as the TypeInfoResolver of the serializer options avoids reflection-based metadata and makes the serializer trimming and Native AOT friendly. See reflection vs source generation for how source generation works in System.Text.Json.

List of Samples