StrongTypedId.NewtonSoft
2.3.1
dotnet add package StrongTypedId.NewtonSoft --version 2.3.1
NuGet\Install-Package StrongTypedId.NewtonSoft -Version 2.3.1
<PackageReference Include="StrongTypedId.NewtonSoft" Version="2.3.1" />
<PackageVersion Include="StrongTypedId.NewtonSoft" Version="2.3.1" />
<PackageReference Include="StrongTypedId.NewtonSoft" />
paket add StrongTypedId.NewtonSoft --version 2.3.1
#r "nuget: StrongTypedId.NewtonSoft, 2.3.1"
#:package StrongTypedId.NewtonSoft@2.3.1
#addin nuget:?package=StrongTypedId.NewtonSoft&version=2.3.1
#tool nuget:?package=StrongTypedId.NewtonSoft&version=2.3.1
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.1)
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 | 86 | 7/11/2025 |
2.3.0 | 138 | 7/6/2025 |
2.2.1 | 65 | 7/5/2025 |
2.2.0 | 891 | 3/12/2025 |
2.1.0 | 162 | 3/12/2025 |
2.0.0 | 8,065 | 12/30/2024 |
1.9.2 | 9,564 | 11/15/2024 |
1.9.1 | 121 | 11/13/2024 |
1.9.0 | 130 | 11/11/2024 |
1.8.0 | 14,146 | 8/26/2024 |
1.7.0 | 15,779 | 5/10/2024 |
1.6.6 | 8,220 | 2/9/2024 |
1.6.5 | 351 | 2/5/2024 |
1.6.4 | 197 | 1/31/2024 |
1.6.3 | 722 | 1/8/2024 |
1.6.2 | 5,677 | 10/10/2023 |
1.6.1 | 433 | 9/8/2023 |
1.6.0 | 209 | 7/18/2023 |
1.5.1 | 239 | 7/15/2023 |
1.5.0 | 244 | 7/15/2023 |
1.4.3 | 211 | 7/11/2023 |
1.4.2 | 208 | 7/11/2023 |
1.4.1 | 214 | 7/11/2023 |
1.4.0 | 207 | 7/10/2023 |
1.3.0 | 236 | 5/21/2023 |
1.2.0 | 399 | 1/21/2023 |
1.1.5 | 1,921 | 8/5/2022 |
1.1.4 | 1,367 | 7/10/2022 |
1.1.3 | 481 | 7/10/2022 |
1.1.2 | 488 | 5/12/2022 |
1.1.1 | 475 | 3/12/2022 |