The package exposes AddToon(...) extension methods for IServiceCollection, IMvcBuilder, and IMvcCoreBuilder.
builder.Services
.AddControllers()
.AddToon();
builder.Services
.AddControllers()
.AddToon(options =>
{
options.Encode.Indent = 1;
options.Encode.Delimiter = ToonDelimiter.COMMA;
options.Encode.KeyFolding = ToonKeyFolding.Off;
options.Encode.ObjectArrayLayout = ToonObjectArrayLayout.Columnar;
options.Encode.ByteArrayFormat = ToonByteArrayFormat.Base64String;
}, useAsDefaultFormatter: false);
Before your callback runs, the formatter registration applies these defaults:
options.Encode.IgnoreNullOrEmpty = true;options.Encode.Delimiter = ToonDelimiter.COMMA;options.Encode.Indent = 1;options.Encode.ExcludeEmptyArrays = true;options.Encode.KeyFolding = ToonKeyFolding.Off;options.Encode.ObjectArrayLayout = ToonObjectArrayLayout.Columnar;options.Encode.ByteArrayFormat = ToonByteArrayFormat.Base64String;This happens so the API transport profile starts from a predictable TOON formatter baseline.
options.Encode.ByteArrayFormat = ToonByteArrayFormat.Base64String; means byte[], List<byte>, and IEnumerable<byte> are written as compact Base64 values by default. Change it to NumericArray when a consumer needs a JSON-like numeric array shape.
useAsDefaultFormatter controls formatter ordering:
false: append TOON formatters to MVC collectionstrue: insert TOON formatters at the front so they become the preferred formatter choiceToonServiceOptionsIToonServiceToonInputFormatterToonOutputFormatterapplication/toon and text/toonThe package avoids duplicate formatter registration when the formatters are already present in MVC options.