Franz.Common.Serialization 3.0.0

dotnet add package Franz.Common.Serialization --version 3.0.0
                    
NuGet\Install-Package Franz.Common.Serialization -Version 3.0.0
                    
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="Franz.Common.Serialization" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Franz.Common.Serialization" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Franz.Common.Serialization" />
                    
Project file
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 Franz.Common.Serialization --version 3.0.0
                    
#r "nuget: Franz.Common.Serialization, 3.0.0"
                    
#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 Franz.Common.Serialization@3.0.0
                    
#: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=Franz.Common.Serialization&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Franz.Common.Serialization&version=3.0.0
                    
Install as a Cake Tool

Franz.Common.Serialization

System.Text.Json serialization contracts with explicit converter composition and UTF-8 byte-array support.

Overview

System.Text.Json serialization contracts with explicit converter composition and UTF-8 byte-array support.

Installation

dotnet add package Franz.Common.Serialization

Register serializer services

using Franz.Common.Serialization.Extensions;

builder.Services.AddSerializers();

The extension registers:

  • IJsonSerializer → SystemTextJsonSerializer as a singleton.
  • IByteArraySerializer → ByteArraySerializer as a singleton.

Both registrations use the Franz no-duplicate registration strategy. The JSON serializer receives the registered IEnumerable<JsonConverter>; add converters explicitly when the application requires them.

JSON contract

IJsonSerializer exposes:

string? Serialize(object? content);
T? Deserialize<T>(string? content);
object? Deserialize(string? content, Type targetType);

The current implementation uses System.Text.Json, not Newtonsoft.Json. Its options use camel-case property naming, case-insensitive property matching, omit null-valued properties when writing, and produce compact JSON. Null input serializes to null; blank input deserializes to the default value/null.

using Franz.Common.Serialization;

public sealed class EventPublisher(IJsonSerializer serializer)
{
    public string? Serialize(OrderCreated message) =>
        serializer.Serialize(message);

    public OrderCreated? Deserialize(string payload) =>
        serializer.Deserialize<OrderCreated>(payload);
}

Default options

FranzJson.Default exposes a static JsonSerializerOptions instance with the same camel-case, case-insensitive, null-omitting, compact defaults. It intentionally does not enable polymorphic type-name deserialization or add custom converters by default.

The registered SystemTextJsonSerializer creates its own options instance and adds the converters supplied through DI; it does not use FranzJson.Default directly.

Native AOT and source-generated metadata

Provide metadata for every root and runtime concrete type that the serializer can process:

[JsonSerializable(typeof(OrderCreated))]
[JsonSerializable(typeof(OrderLine))]
internal partial class AppJsonContext : JsonSerializerContext { }

builder.Services.AddSerializers(AppJsonContext.Default);

The serializer resolves JsonTypeInfo from the supplied context for both generic and runtime-type operations. Missing metadata fails explicitly; it does not fall back to reflection. SystemTextCreationConverter<T> uses the active options resolver for its concrete runtime type, so that type must also be present in the context.

For domain enumerations, register a closed converter instance explicitly:

services.AddSingleton<JsonConverter>(
    new EnumerationValueJsonConverter<OrderStatus, int>());
services.AddSerializers(AppJsonContext.Default);

The reflection-based EnumerationJsonConverter factory is retained for JIT compatibility and is annotated as requiring dynamic code. It is not the Native AOT path.

Custom converters

The assembly contains converter types such as DateTimeJsonConverter, DateTimeOffsetJsonConverter, and EnumerationJsonConverter. Their presence does not mean they are automatically registered. Register the required JsonConverter instances with DI before calling AddSerializers(), or configure a serializer instance explicitly where appropriate.

Byte-array contract

ByteArraySerializer serializes an object through IJsonSerializer, then encodes the JSON as UTF-8 bytes. Deserialization decodes UTF-8 and delegates to the JSON serializer. A null object produces an empty byte array; null byte input produces the default result.

This is JSON encoded as UTF-8, not a binary object serializer or a compression format. Do not use it when a protocol requires a distinct binary schema.

Security and compatibility

Do not add polymorphic type activation for untrusted payloads without a strict allow-list and a reviewed threat model. Treat converter behavior, naming policy, null handling, and date/time representation as wire-contract decisions; cover changes with compatibility tests.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Franz.Common.Serialization:

Package Downloads
Franz.Common.Messaging

Shared utility library for the Franz Framework.

Franz.Common.Messaging.Hosting

Shared utility library for the Franz Framework.

Franz.Common.Http

Shared utility library for the Franz Framework.

Franz.Common.Http.Headers

Shared utility library for the Franz Framework.

Franz.Common.Http.Client

Shared utility library for the Franz Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 79 11/10/2026
2.3.4 618 11/1/2026
2.3.3 552 10/28/2026
2.3.2 352 10/27/2026
2.3.1 414 10/26/2026
2.3.0 526 7/21/2026
2.2.19 405 7/19/2026
2.2.18 410 7/19/2026
2.2.17 504 7/12/2026
2.2.16 411 7/2/2026
2.2.15 423 6/29/2026
2.2.14 408 6/29/2026
2.2.13 415 6/29/2026
2.2.12 404 6/28/2026
2.2.11 415 6/28/2026
2.2.10 411 6/28/2026
2.2.9 411 6/28/2026
2.2.8 409 6/28/2026
2.2.7 484 6/7/2026
2.2.6 407 6/6/2026
Loading failed