Nerdbank.Json
0.2.15-alpha
Prefix Reserved
dotnet add package Nerdbank.Json --version 0.2.15-alpha
NuGet\Install-Package Nerdbank.Json -Version 0.2.15-alpha
<PackageReference Include="Nerdbank.Json" Version="0.2.15-alpha" />
<PackageVersion Include="Nerdbank.Json" Version="0.2.15-alpha" />
<PackageReference Include="Nerdbank.Json" />
paket add Nerdbank.Json --version 0.2.15-alpha
#r "nuget: Nerdbank.Json, 0.2.15-alpha"
#:package Nerdbank.Json@0.2.15-alpha
#addin nuget:?package=Nerdbank.Json&version=0.2.15-alpha&prerelease
#tool nuget:?package=Nerdbank.Json&version=0.2.15-alpha&prerelease
Nerdbank.Json
Nerdbank.Json is a UTF-8 JSON serializer being built in the same general shape as Nerdbank.MessagePack, but without layering on top of System.Text.Json, Newtonsoft.Json, or any other serializer.
The implementation includes low-level UTF-8 readers and writers, built-in converters for common .NET types, and PolyType-backed serialization for mutable and constructor-bound object graphs.
It is allocation-conscious in the hot path and multi-targets net8.0, net9.0, net472, and netstandard2.0.
Features
- Direct UTF-8 JSON writing to
IBufferWriter<byte>. - RFC 8259 string escaping, limited to the characters that must be escaped.
- Built-in serialization and deserialization for common .NET primitive and BCL types.
- PolyType-driven serialization for mutable objects, records, and immutable constructor-bound contracts.
- Mutable, read-only, and immutable collections when their shapes supply a construction strategy.
- Dictionaries with supported scalar or enum keys, and member-specific comparers through
UseComparerAttribute. - Rectangular multidimensional arrays with nested or flat dimensions/data representations.
- camelCase property naming by default, configurable with
JsonNamingPolicy. - Optional indented output for human-readable JSON.
- Optional case-insensitive property-name matching during deserialization.
- Optional enum-name serialization with numeric fallback for unnamed values.
- Runtime custom converter registration with converter instances, converter types, or converter factories.
- Attribute-driven custom converter registration on types, properties, and constructor parameters.
- Optional unknown-member retention through a type-recognized
UnusedDataPacketfield or property. - Built-in byte buffer handling using Base64 JSON strings.
- Optional trailing-comma and comment skipping support during deserialization.
- Configurable deserialization policy for missing required values and non-nullable reference validation.
- Reference preservation for shared instances, with optional cycles through mutable objects and collections, using JSON
$id,$ref, and$valuemetadata. - Synchronous stream and incremental asynchronous stream and pipe overloads.
- Sequence streaming through
DeserializeEnumerableAsyncandSerializeEnumerableAsync, with NDJSON or JSON-array framing selected byJsonSerializer.SequenceOptions. - Typed and raw JSON paths through
DeserializePathandDeserializePathEnumerableAsync. - Generated and runtime unions configured through
DerivedTypeUnionsandDerivedShapeMapping<T>. - JSON Schema export as a mutable
System.Text.Json.Nodes.JsonObject. - Opt-in
JsonValue, object, dynamic, expando, and System.Text.Json DOM converters throughOptionalConvertersextensions. - Multi-targeting across modern .NET and .NET Framework.
- Test-driven development with focused round-trip coverage for the current built-in type surface.
Supported Built-In Types
The current built-in serializer supports:
string,char,bool- Numeric primitives:
byte,sbyte,short,ushort,int,uint,long,ulong,float,double,decimal System.Numerics.BigIntegerDateTime,DateTimeOffset,TimeSpanGuid,Version,Uri,CultureInfo,Encodingbyte[],Memory<byte>,ReadOnlyMemory<byte>System.Drawing.Color,System.Drawing.Point- On .NET 8 and later:
Half,Int128,UInt128,DateOnly,TimeOnly,Rune
Usage
Annotate a partial root contract with PolyType's GenerateShape attribute and use JsonSerializer.Serialize and Deserialize with its generated shape.
Serialize returns a string by default; buffer-writer, stream, and pipe overloads support direct UTF-8 output.
See the getting-started sample and usage guide.
Object property names default to camelCase.
Set PropertyNamingPolicy to null to preserve declared names, or choose another JsonNamingPolicy.
Dictionary keys remain unchanged unless DictionaryKeyNamingPolicy is set separately.
AllowTrailingCommas and ReadCommentHandling optionally accept human-authored JSON.
Register converter instances, types, or factories through Converters, ConverterTypes, and ConverterFactories.
ConverterTypeCollection supports collection expressions and an explicit Create builder.
Factories resolve supporting converters through ConverterContext; converters processing nested values use SerializationContext.GetConverter instead of calling the top-level serializer.
See the custom-converter samples.
To retain unknown members, declare a field or property of type UnusedDataPacket.
For a private member, include it in the shape with PolyType's PropertyShape attribute.
Retained payloads are re-emitted as raw JSON without introducing a property for the packet itself.
See retaining unknown members.
SerializeDefaultValues honors optional constructor defaults and DefaultValueAttribute when deciding whether to omit a property.
The feature guide describes supported contracts and limitations.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- Microsoft.VisualStudio.Validation (>= 17.13.22)
- Nerdbank.MessagePack (>= 1.5.47-alpha)
- PolyType (>= 2.0.0-rc.4)
- System.Buffers (>= 4.6.1)
- System.IO.Pipelines (>= 10.0.14)
- System.Memory (>= 4.6.3)
-
.NETStandard 2.0
- Microsoft.VisualStudio.Validation (>= 17.13.22)
- Nerdbank.MessagePack (>= 1.5.47-alpha)
- PolyType (>= 2.0.0-rc.4)
- System.Buffers (>= 4.6.1)
- System.IO.Pipelines (>= 10.0.14)
- System.Memory (>= 4.6.3)
-
net10.0
- Microsoft.VisualStudio.Validation (>= 17.13.22)
- Nerdbank.MessagePack (>= 1.5.47-alpha)
- PolyType (>= 2.0.0-rc.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Nerdbank.Json:
| Package | Downloads |
|---|---|
|
Nerdbank.Json.AspNetCoreMvcFormatter
ASP.NET Core MVC input and output formatters backed by Nerdbank.Json, enabling AOT-safe, source-generated JSON in MVC and minimal-hosting Web APIs with an explicitly supplied ITypeShapeProvider. |
|
|
Nerdbank.JsonRpc
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.15-alpha | 66 | 11/7/2026 |
| 0.2.7-alpha | 70 | 10/28/2026 |
| 0.2.1-alpha | 460 | 10/22/2026 |
| 0.1.1092-alpha | 194 | 10/17/2026 |
| 0.1.1066-alpha | 451 | 9/30/2026 |
| 0.1.1057-alpha | 234 | 9/29/2026 |
| 0.1.1050-alpha | 77 | 9/26/2026 |
| 0.1.1041-alpha | 80 | 9/25/2026 |
| 0.1.1010-alpha | 428 | 9/1/2026 |