ServiceBus.Formatters 1.4.2

dotnet add package ServiceBus.Formatters --version 1.4.2
                    
NuGet\Install-Package ServiceBus.Formatters -Version 1.4.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ServiceBus.Formatters" Version="1.4.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ServiceBus.Formatters" Version="1.4.2" />
                    
Directory.Packages.props
<PackageReference Include="ServiceBus.Formatters" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ServiceBus.Formatters --version 1.4.2
                    
#r "nuget: ServiceBus.Formatters, 1.4.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ServiceBus.Formatters@1.4.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ServiceBus.Formatters&version=1.4.2
                    
Install as a Cake Addin
#tool nuget:?package=ServiceBus.Formatters&version=1.4.2
                    
Install as a Cake Tool

ServiceBus.Formatters

The serialization contract used by ServiceBus.Core: how a message becomes the bytes sent through the broker and back. Two packages implement it, ServiceBus.Formatters.Ms (System.Text.Json) and ServiceBus.Formatters.Newtonsoft (Newtonsoft.Json), and they are interchangeable behind it. You normally install one of them, which brings this package with it.

The contract

IDataFormatter joins an encoder and a decoder:

Member What it does
Encode(object) writes a value as bytes
Decode<TData>(byte[]), Decode<TData>(ReadOnlyMemory<byte>) reads a value of a known type
Decode(byte[], Type), Decode(ReadOnlyMemory<byte>, Type) reads a value of a type known only at run time
Encoder the Encoding of the text

IJsonSerializer does the same for JSON text instead of bytes.

What every implementation does

Case Result
Payload that starts with a byte order mark read normally; the mark is never written
Empty payload (no bytes, only the mark, or only JSON white space) "no value": null for a reference type or a Nullable<T>, an exception for any other value type
null array ArgumentNullException (a mistake of the caller, not an empty message)

A subscriber therefore receives Data = null for an empty message, whichever formatter is used.

Choosing one

ServiceBus.Formatters.Ms ServiceBus.Formatters.Newtonsoft
Serializer System.Text.Json Newtonsoft.Json
Encoding UTF-8 only any Encoding
Speed and memory faster, allocates less slower, allocates more

In the benchmark of the repository (tools/FormatterBenchmark, messages from 196 bytes to 93 KB) System.Text.Json decodes about 1.4 to 1.7 times and encodes about 1.8 to 1.9 times faster than the Newtonsoft formatters, and allocates 20 to 27% less decoding and about 60% less encoding.

Targets: net8.0, net9.0, net10.0. netstandard2.1 and net6.0 are no longer targets: applications on them stay on the earlier releases. See the documentation.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ServiceBus.Formatters:

Package Downloads
ServiceBus.Core.Rabbit

This is a custom library which implements ServiceBus.Core contracts, using RabbitMq as underlying service bus layer.

ServiceBus.Formatters.Ms

This is an easy library which exposes some contracts used to serialize and deserialize messages incoming from ESB brokers, based in microsoft serializer.

ServiceBus.Formatters.Newtonsoft

This is easy library which exposes some contracts used to serialize and deserialize messages incoming from ESB brokers, based in newtownsoft serializer.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.2 230 11/20/2026
1.4.1 1,450 1/22/2026
1.4.0 3,735 3/6/2025
1.3.0 1,195 10/16/2024
1.2.0 438 10/2/2024
1.1.0 600 8/28/2024
1.0.2 3,148 7/17/2023
1.0.1 450 7/15/2023