![]() |
VOOZH | about |
dotnet add package NEventStore.Serialization.Json --version 10.2.0
NuGet\Install-Package NEventStore.Serialization.Json -Version 10.2.0
<PackageReference Include="NEventStore.Serialization.Json" Version="10.2.0" />
<PackageVersion Include="NEventStore.Serialization.Json" Version="10.2.0" />Directory.Packages.props
<PackageReference Include="NEventStore.Serialization.Json" />Project file
paket add NEventStore.Serialization.Json --version 10.2.0
#r "nuget: NEventStore.Serialization.Json, 10.2.0"
#:package NEventStore.Serialization.Json@10.2.0
#addin nuget:?package=NEventStore.Serialization.Json&version=10.2.0Install as a Cake Addin
#tool nuget:?package=NEventStore.Serialization.Json&version=10.2.0Install as a Cake Tool
NEventStore.Serialization.Json is the Newtonsoft.Json serializer for NEventStore. It is the compatibility contract that the System.Text.Json serializer follows so either package can be used for the same persisted JSON.
var store = Wireup.Init()
.UsingInMemoryPersistence()
.UsingJsonSerialization()
.Build();
Custom Newtonsoft settings can be supplied, and root known types can be overridden:
var serializer = new JsonSerializer(
new JsonSerializerSettings(),
typeof(List<EventMessage>),
typeof(Dictionary<string, object>));
The default known types are:
List<EventMessage>Dictionary<string, object>Passing null or an empty known-type array keeps those defaults. Passing a non-empty array replaces them.
The serializer has two internal Newtonsoft serializers:
TypeNameHandling.Auto, DefaultValueHandling.Ignore, NullValueHandling.Ignore.TypeNameHandling.All, DefaultValueHandling.Ignore, NullValueHandling.Ignore.Known root types are intentionally written without a root $type wrapper. Their polymorphic object members still receive $type metadata when the runtime value is not assignable from the declared type. This is what preserves event body, header, and snapshot payload types.
Unknown root types are written with root $type metadata. This keeps snapshots and custom serialized root objects self-describing.
The JSON contract is based on Newtonsoft.Json metadata names:
$type stores an assembly-qualified CLR type name.$values stores array contents when the typed value itself is an array or collection.$type metadata.object values are read and written with $type metadata when needed.The System.Text.Json serializer emits and reads the same metadata contract for the NEventStore cases that require polymorphism. The two serializers are wire-compatible; they are not required to produce byte-for-byte identical JSON when static property types already provide enough type information.
Assembly versions are shortened in these examples. Real payloads contain full assembly-qualified names.
Source object:
var messages = new List<EventMessage>
{
new EventMessage { Body = "some value" },
new EventMessage { Body = 42 },
new EventMessage { Body = new SimpleMessage { Count = 1234, Value = "Hello" } }
};
JSON shape:
[
{
"Headers": {},
"Body": "some value"
},
{
"Headers": {},
"Body": 42
},
{
"Headers": {},
"Body": {
"$type": "NEventStore.Persistence.AcceptanceTests.SimpleMessage, NEventStore.Persistence.AcceptanceTests",
"Id": "00000000-0000-0000-0000-000000000000",
"Created": "0001-01-01T00:00:00",
"Value": "Hello",
"Count": 1234,
"Contents": []
}
}
]
List<EventMessage> is a known root type, so the array has no root $type. The third Body is declared as object, so it has $type metadata.
Source object:
var headers = new Dictionary<string, object>
{
["HeaderKey"] = "SomeValue",
["NumericKey"] = 42,
["ComplexKey"] = new SimpleMessage { Count = 1234 }
};
JSON shape:
{
"HeaderKey": "SomeValue",
"NumericKey": 42,
"ComplexKey": {
"$type": "NEventStore.Persistence.AcceptanceTests.SimpleMessage, NEventStore.Persistence.AcceptanceTests",
"Id": "00000000-0000-0000-0000-000000000000",
"Created": "0001-01-01T00:00:00",
"Count": 1234,
"Contents": []
}
}
Dictionary<string, object> is a known root type, so the dictionary itself has no root $type. Complex values are typed.
Source object:
var snapshot = new Snapshot("stream-1", 42, new Dictionary<string, List<int>>
{
["values"] = [1, 2, 3]
});
JSON shape:
{
"$type": "NEventStore.Snapshot, NEventStore",
"BucketId": "default",
"StreamId": "stream-1",
"StreamRevision": 42,
"Payload": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String,...],[System.Collections.Generic.List`1[[System.Int32,...]],...]], ...",
"values": {
"$type": "System.Collections.Generic.List`1[[System.Int32,...]], ...",
"$values": [1, 2, 3]
}
}
}
Snapshot is not a known root type, so the root has $type. Its Payload property is declared as object, so the dictionary payload is typed. The nested list uses $values because typed collections are represented as objects with metadata plus values.
The test suite verifies:
The mirrored System.Text.Json tests verify the reverse direction.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on NEventStore.Serialization.Json:
| Package | Downloads |
|---|---|
|
EventSaucing
An event source stack based on NEventStore and Akka |
|
|
domainD.Repository.NEventStore
domainD repository implementation using NEventStore |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.2.0 | 92 | 6/15/2026 |
| 10.1.1 | 9,039 | 5/15/2025 |
| 10.1.0 | 1,588 | 4/22/2025 |
| 10.0.0 | 9,773 | 1/24/2025 |
| 9.2.0 | 2,699 | 12/23/2024 |
| 9.1.1 | 164,963 | 8/1/2023 |
| 9.0.1 | 137,911 | 12/29/2021 |
| 9.0.0 | 4,675 | 12/3/2021 |
| 8.0.0 | 32,773 | 12/18/2020 |
| 7.0.0 | 133,849 | 7/17/2019 |
| 6.1.0 | 4,249 | 7/5/2019 |
| 6.0.0 | 36,987 | 3/27/2019 |
| 6.0.0-rc-1 | 1,572 | 2/15/2019 |
| 6.0.0-rc-0 | 1,743 | 12/19/2018 |
| 4.1.0.10 | 107,179 | 9/23/2013 |
| 4.0.0.15 | 5,007 | 8/22/2013 |