Fast.Serialization.Newtonsoft.Json
Public members, parameters, returns, and exceptions
Reference source version 3.5.28. Targets: net8.0;net9.0;net10.0.
Centrally managed Microsoft.AspNetCore.Mvc.NewtonsoftJson versions are now 8.0.33 / 9.0.22 / 10.0.14 for net8.0 / net9.0 / net10.0. The module version is 3.5.28; serialization public APIs are unchanged.
Contract and constraints
Newtonsoft.Json integration in the Fast.Serialization namespace. Service collection registration initializes shared tool options; MVC builder registration enables the MVC Newtonsoft formatter. Calling only the service extension does not switch MVC. The callback currently affects static tool options, so configure MVC overrides separately through MVC options. Minimal API System.Text.Json is not changed. ToJsonString, ToObject and DeepCopy use JsonContext.SerializerOptions. A copy retains only data allowed by serializer settings, converters and attributes. Invalid JSON and null-input errors follow the extension and Newtonsoft.Json contracts; there is no guarantee of a fresh object on failure. Do not reference both Fast.Serialization implementations together: their namespaces and public names overlap.
Installation and examples
Install the package
dotnet add package Fast.Serialization.Newtonsoft.JsonExample 1
using Fast.Serialization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSerialization();
builder.Services.AddControllers().AddSerialization();
var app = builder.Build();
app.MapControllers();
app.Run();Example 2
using Fast.Serialization;
public sealed class ItemSnapshot
{
public long Id { get; set; }
public string Name { get; set; } = "";
}
public sealed class SnapshotCodec
{
public string Encode(ItemSnapshot item) => item.ToJsonString();
public ItemSnapshot Decode(string json) => json.ToObject<ItemSnapshot>();
public ItemSnapshot Copy(ItemSnapshot item) => item.DeepCopy();
}Web-host examples belong in a consumer project using Microsoft.NET.Sdk.Web and a supported .NET target. IaaS examples can be used in an ordinary class library. Registration precedes builder.Build(); configure middleware and endpoints before app.Run(). Samples retain their original code and comments. The source module was built in Release and its local NuGet package identity, target assets and dependencies were verified for net8.0, net9.0 and net10.0. These registration and codec snippets were not compiled in this update. No host, external service, database operation, protocol compatibility test or client generator was run.
Source reference
Decimal precision
Default decimal/nullable-decimal output keeps the decimal value without conversion through double. Explicit Places still applies the existing Math.Round policy; null remains null. JavaScript number precision is a separate consumer constraint and may require a suitable high-precision representation.
2026-10-30 dependency patch updates
Fast.Serialization.Newtonsoft.Json increments from 3.5.27 to 3.5.28. For net8.0 / net9.0 / net10.0, Microsoft.AspNetCore.Mvc.NewtonsoftJson uses 8.0.33 / 9.0.22 / 10.0.14. Newtonsoft.Json 13.0.4 is unchanged.
This dependency update does not modify module implementation or public APIs. Restore, Release builds and local packaging passed for all three targets without final build warnings or errors. Package identity, dependency groups and DLL/XML equality with build outputs were verified. No host, HTTP/serialization/ORM runtime regression, database or Redis operation was run; consumer examples on this page were not recompiled.
