Partial.SystemTextJson
8.0.5-rc1
dotnet add package Partial.SystemTextJson --version 8.0.5-rc1
NuGet\Install-Package Partial.SystemTextJson -Version 8.0.5-rc1
<PackageReference Include="Partial.SystemTextJson" Version="8.0.5-rc1" />
<PackageVersion Include="Partial.SystemTextJson" Version="8.0.5-rc1" />
<PackageReference Include="Partial.SystemTextJson" />
paket add Partial.SystemTextJson --version 8.0.5-rc1
#r "nuget: Partial.SystemTextJson, 8.0.5-rc1"
#:package Partial.SystemTextJson@8.0.5-rc1
#addin nuget:?package=Partial.SystemTextJson&version=8.0.5-rc1&prerelease
#tool nuget:?package=Partial.SystemTextJson&version=8.0.5-rc1&prerelease
Partial.SystemTextJson
System.Text.Json integration for Partial. Provides PartialJsonConverter which enables automatic property tracking during System.Text.Json deserialization.
Overview
When deserializing JSON into a partial model using the standard System.Text.Json deserializer, the property tracking information is lost because the default converter doesn't notify the Partial<TSelf> base class about which properties were actually present in the Json.
PartialJsonConverter solves this by implementing a custom JsonConverterFactory that properly tracks which properties are deserialized, allowing IsDefined() and IsUndefined() to work correctly.
Installation
dotnet add package Partial.SystemTextJson
This will automatically include Partial.Core as a dependency.
Usage
Basic Setup
Register the converter with your JsonSerializerOptions:
using System.Text.Json;
using System.Text.Json.Serialization;
using Partial.SystemTextJson;
var options = new JsonSerializerOptions
{
Converters = { new PartialJsonConverter() }
};
Deserialization
var json = """
{
"username": "alice",
"email": "alice@example.com"
}
""";
var user = JsonSerializer.Deserialize<UserUpdate>(json, options);
// Properties from Json are now tracked
if (user.IsDefined(u => u.Username)) { /* true */ }
if (user.IsDefined(u => u.Email)) { /* true */ }
if (user.IsUndefined(u => u.Age)) { /* true */ }
Serialization
Only properties that were defined are serialized back to Json:
var user = JsonSerializer.Deserialize<UserUpdate>(json, options);
var serialized = JsonSerializer.Serialize(user, options);
// Result contains only the properties that were defined:
Console.WriteLine(serialized); // {"username": "alice", "email": "alice@example.com"}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 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. |
-
net8.0
- Partial.Core (>= 1.0.0-rc1)
- System.Text.Json (>= 8.0.5)
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 |
|---|---|---|
| 8.0.5-rc1 | 92 | 2/13/2026 |