Message serialization with System.Text.Json is bundled into NServiceBus version 8.1 and above. The built-in serializer is fully compatible with the community-created NServiceBus.Json package.
Conversion from community package
First, upgrade to NServiceBus 8.1.0 or newer.
Then, instead of:
var serialization = endpointConfiguration.UseSerialization<NServiceBus.Json.SystemJsonSerializer>();
Remove the reference to the NServiceBus.Json NuGet package and use:
var serialization = endpointConfiguration.UseSerialization<NServiceBus.SystemJsonSerializer>();
If full namespaces are not used, this code change may not be necessary, and instead, the using NServiceBus.
statement can be removed.
API differences
Specifying content type
The ContentTypeKey(.
method has been renamed to ContentType(.
.
Options
The low level .
and WriterOptions(.
is no longer available and it's recommended to use the JsonSerializerOptions to control serialization and deserialization behavior.