StrongTypedId.NewtonSoft
2.3.0
See the version list below for details.
dotnet add package StrongTypedId.NewtonSoft --version 2.3.0
NuGet\Install-Package StrongTypedId.NewtonSoft -Version 2.3.0
<PackageReference Include="StrongTypedId.NewtonSoft" Version="2.3.0" />
<PackageVersion Include="StrongTypedId.NewtonSoft" Version="2.3.0" />
<PackageReference Include="StrongTypedId.NewtonSoft" />
paket add StrongTypedId.NewtonSoft --version 2.3.0
#r "nuget: StrongTypedId.NewtonSoft, 2.3.0"
#:package StrongTypedId.NewtonSoft@2.3.0
#addin nuget:?package=StrongTypedId.NewtonSoft&version=2.3.0
#tool nuget:?package=StrongTypedId.NewtonSoft&version=2.3.0
StrongTypedId.NewtonSoft
This package provides support for using StrongTypedId with the NewtonSoft JSON serializer.
Usage
First add the StrongTypedNewtonSoftJsonConverter
to your serializer settings.
var settings = new JsonSerializerSettings
{
Converters = { new StrongTypedNewtonSoftJsonConverter() }
};
var json = JsonConvert.SerializeObject(UserId.New(), settings);
OR
var serializer = new JsonSerializer()
{
Converters = { new StrongTypedNewtonSoftJsonConverter() }
};
var json = serializer.Serialize(writer, UserId.New());
This will serialize any StrongTypedId
, StrongTypedGuid
or StrongTypedValue
with explicit type information,
allowing deserialization even if your model is abstract.
If you furthermore have types you'd prefer serialized as their underlying value, you can add a
Newtonsoft.Json.JsonConverter
attribute to the type:
[StrongTypedValueJsonConverterFactory]
[Newtonsoft.Json.JsonConverter(typeof(NewtonSoftJsonConverter<UserId, Guid>))] // This is the converter for NewtonSoft.
public class UserId: StrongTypedId<UserId, Guid>
{
public UserId(Guid value) : base(value)
{
}
}
Notice how you can have both JsonConverters applied simultaneously to support both WebAPI and NewtonSoft at the same time.
Documentation
Auto generated documentation via DocFx is available here: https://steffenskov.github.io/StrongTypedId/
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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 was computed. 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. |
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
- StrongTypedId (>= 2.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.3.1 | 112 | 7/11/2025 |
2.3.0 | 143 | 7/6/2025 |
2.2.1 | 68 | 7/5/2025 |
2.2.0 | 895 | 3/12/2025 |
2.1.0 | 165 | 3/12/2025 |
2.0.0 | 8,068 | 12/30/2024 |
1.9.2 | 9,568 | 11/15/2024 |
1.9.1 | 123 | 11/13/2024 |
1.9.0 | 132 | 11/11/2024 |
1.8.0 | 14,149 | 8/26/2024 |
1.7.0 | 15,781 | 5/10/2024 |
1.6.6 | 8,222 | 2/9/2024 |
1.6.5 | 355 | 2/5/2024 |
1.6.4 | 199 | 1/31/2024 |
1.6.3 | 724 | 1/8/2024 |
1.6.2 | 5,679 | 10/10/2023 |
1.6.1 | 438 | 9/8/2023 |
1.6.0 | 213 | 7/18/2023 |
1.5.1 | 245 | 7/15/2023 |
1.5.0 | 248 | 7/15/2023 |
1.4.3 | 215 | 7/11/2023 |
1.4.2 | 212 | 7/11/2023 |
1.4.1 | 219 | 7/11/2023 |
1.4.0 | 211 | 7/10/2023 |
1.3.0 | 242 | 5/21/2023 |
1.2.0 | 404 | 1/21/2023 |
1.1.5 | 1,926 | 8/5/2022 |
1.1.4 | 1,370 | 7/10/2022 |
1.1.3 | 487 | 7/10/2022 |
1.1.2 | 492 | 5/12/2022 |
1.1.1 | 480 | 3/12/2022 |