ToonService is the recommended integration point when TOON should be configured once and reused throughout an application.
using Microsoft.Extensions.DependencyInjection;
using DevOp.Toon.Core;
using DevOp.Toon;
var services = new ServiceCollection();
services.AddToon(options =>
{
options.Indent = 2;
options.Delimiter = ToonDelimiter.COMMA;
options.KeyFolding = ToonKeyFolding.Safe;
options.ObjectArrayLayout = ToonObjectArrayLayout.Columnar;
options.Strict = true;
options.ExpandPaths = ToonPathExpansion.Off;
});
AddToon(...) registers:
ToonServiceOptions as a singletonIToonService backed by ToonServicevar provider = services.BuildServiceProvider();
var toon = provider.GetRequiredService<IToonService>();
string encoded = toon.Encode(new { Id = 42, Name = "Widget" });
string json = toon.Toon2Json(encoded);
IToonServiceUse the service abstraction when you want:
ToonServiceOptions combines encode and decode configuration:
IndentDelimiterKeyFoldingFlattenDepthObjectArrayLayoutStrictExpandPathsRecommended default story: for customer-facing and production-oriented examples, the strongest current profile is columnar object arrays with null and empty-array reduction enabled on the encode side.