PosInformatique.Foundations.People.Json
1.2.0-rc.1
Prefix Reserved
This is a prerelease version of PosInformatique.Foundations.People.Json.
dotnet add package PosInformatique.Foundations.People.Json --version 1.2.0-rc.1
NuGet\Install-Package PosInformatique.Foundations.People.Json -Version 1.2.0-rc.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PosInformatique.Foundations.People.Json" Version="1.2.0-rc.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.People.Json" Version="1.2.0-rc.1" />
<PackageReference Include="PosInformatique.Foundations.People.Json" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PosInformatique.Foundations.People.Json --version 1.2.0-rc.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PosInformatique.Foundations.People.Json, 1.2.0-rc.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PosInformatique.Foundations.People.Json@1.2.0-rc.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PosInformatique.Foundations.People.Json&version=1.2.0-rc.1&prerelease
#tool nuget:?package=PosInformatique.Foundations.People.Json&version=1.2.0-rc.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PosInformatique.Foundations.People.Json
Introduction
Provides System.Text.Json converters for the FirstName and LastName value objects from
PosInformatique.Foundations.People. Enables seamless serialization and deserialization of validated names within JSON documents.
Install
You can install the package from NuGet:
dotnet add package PosInformatique.Foundations.People.Json
This package depends on the base package PosInformatique.Foundations.People.
Features
JsonConverter<FirstName>andJsonConverter<LastName>for serialization and deserialization.- Validation on deserialization using
FirstName.TryCreateandLastName.TryCreate(throwsJsonExceptionon invalid input). - Usable via
[JsonConverter]attribute or viaJsonSerializerOptionsextension methodAddPeopleConverters().
Use cases
- Serialization: Persist
FirstNameandLastNameas JSON strings. - Validation: Ensure only valid names are accepted in JSON payloads.
- Integration: Plug directly into
System.Text.Jsonconfiguration.
Examples
Example 1: DTOs with [JsonConverter] attributes
using System.Text.Json;
using System.Text.Json.Serialization;
using PosInformatique.Foundations;
using PosInformatique.Foundations.People.Json;
public sealed class PersonDto
{
[JsonConverter(typeof(FirstNameJsonConverter))]
public FirstName? FirstName { get; set; }
[JsonConverter(typeof(LastNameJsonConverter))]
public LastName? LastName { get; set; }
}
// Serialization
var dto = new PersonDto
{
FirstName = FirstName.Create("John"),
LastName = LastName.Create("Doe")
};
var json = JsonSerializer.Serialize(dto);
// Result: {"FirstName":"John","LastName":"Doe"}
// Deserialization
var input = "{ \"FirstName\": \"Alice\", \"LastName\": \"Smith\" }";
var deserialized = JsonSerializer.Deserialize<PersonDto>(input);
Example 2: Register converters globally with options
using System.Text.Json;
using PosInformatique.Foundations;
using PosInformatique.Foundations.People.Json;
public sealed class EmployeeDto
{
public FirstName? FirstName { get; set; }
public LastName? LastName { get; set; }
}
var options = new JsonSerializerOptions().AddPeopleConverters();
// Serialization
var employee = new EmployeeDto
{
FirstName = FirstName.Create("Bob"),
LastName = LastName.Create("Marley")
};
var json = JsonSerializer.Serialize(employee, options);
// Result: {"FirstName":"Bob","LastName":"Marley"}
// Deserialization
var input = "{ \"FirstName\": \"Carol\", \"LastName\": \"Johnson\" }";
var deserialized = JsonSerializer.Deserialize<EmployeeDto>(input, options);
Example 3: Handling nulls and invalid values
using System.Text.Json;
using PosInformatique.Foundations;
using PosInformatique.Foundations.People.Json;
var options = new JsonSerializerOptions().AddPeopleConverters();
// Null handling
var jsonWithNulls = "{ \"FirstName\": null, \"LastName\": \"Doe\" }";
var obj = JsonSerializer.Deserialize<EmployeeDto>(jsonWithNulls, options);
// obj.FirstName == null, obj.LastName == "Doe"
// Invalid value causes JsonException
try
{
var invalid = "{ \"FirstName\": \"\", \"LastName\": \"Doe\" }";
JsonSerializer.Deserialize<EmployeeDto>(invalid, options);
}
catch (JsonException ex)
{
// "'': is not a valid first name." (message from converter)
}
Links
| 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 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- PosInformatique.Foundations.People (>= 1.2.0-rc.1)
-
net8.0
- PosInformatique.Foundations.People (>= 1.2.0-rc.1)
-
net9.0
- PosInformatique.Foundations.People (>= 1.2.0-rc.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 |
|---|---|---|
| 1.2.0-rc.1 | 71 | 3/31/2026 |
| 1.1.0 | 113 | 3/30/2026 |
| 1.1.0-rc.3 | 72 | 3/27/2026 |
| 1.1.0-rc.2 | 72 | 1/26/2026 |
| 1.1.0-rc.1 | 89 | 1/23/2026 |
| 1.0.0 | 486 | 11/19/2025 |
| 1.0.0-rc.4 | 400 | 11/19/2025 |
| 1.0.0-rc.3 | 393 | 11/18/2025 |
| 1.0.0-rc.2 | 387 | 11/18/2025 |
| 1.0.0-rc.1 | 390 | 11/18/2025 |
1.0.0
- Initial release with the support JSON serialization (with System.Text.Json) for FirstName and LastName value objects.