Lyo.Common.Json 2.0.0

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

Lyo.Common.Json

The JSON contract Lyo APIs, clients, and message-queue envelopes serialize against lives in Lyo.Common.Json: camelCase properties, case-insensitive reads, nulls omitted on write, camelCase string enums, and ReferenceHandler.IgnoreCycles so EF-shaped graphs serialize without blowing up.

Converters under JsonConverters/ stay unregistered by default. They exist for vendor payloads that quote numbers or spell booleans as 0 / 1; add them per integration through LyoJsonSerializerOptionsBuilder.

Lyo.Common.Metadata is intentionally not referenced. The two converters that need registry records ship there, which keeps both packages acyclic. Namespaces match the package: options are Lyo.Common.Json.LyoJsonSerializerOptions and converters live in Lyo.Common.Json.JsonConverters.

Features

  • LyoJsonSerializerOptions. Create() returns a fresh options instance — safe to hand to DI or mutate further — and Create(configure) applies a delegate to it. ApplyTo(target) copies the defaults onto an existing instance for ASP.NET Core's ConfigureHttpJsonOptions, which requires in-place mutation, and skips converters already present.
  • LyoJsonSerializerOptionsBuilder. Fluent composition over the defaults, or over a supplied baseline: AddConverter, WithWriteIndented, WithDefaultIgnoreCondition, then Build() for a copy.
  • ObjectJsonConverter. Opt-in STJ adapter over TypeConversion.FromJsonElement: object properties and collection items deserialize as CLR primitives (string, number, bool, list) instead of JsonElement.
  • String-wrapped booleans. StringIntBoolConverter and its nullable counterpart accept real JSON booleans, numbers, and quoted spellings alike.
  • StringEnumConverter<TEnum>. Enum round-tripping for a specific enum type, for the cases where the suite-wide JsonStringEnumConverter naming policy is not what the upstream sends.
  • StringDateTimeConverter. Constructed with the exact formats an integration uses (params string[] formats), for upstreams whose timestamps are not round-trippable.

Examples

Serialize against the shared contract

using Lyo.Common.Json;

var options = LyoJsonSerializerOptions.Create();
var json = JsonSerializer.Serialize(dto, options);
var back = JsonSerializer.Deserialize<MyDto>(json, options);

Apply the defaults to ASP.NET Core

using Lyo.Common.Json;

// ConfigureHttpJsonOptions hands you the live instance, so copy onto it rather than replacing it.
builder.Services.ConfigureHttpJsonOptions(o => LyoJsonSerializerOptions.ApplyTo(o.SerializerOptions));

A variant for one integration

using Lyo.Common.Json;
using Lyo.Common.Json.JsonConverters;

// This upstream quotes its numbers and sends booleans as 0/1.
var options = new LyoJsonSerializerOptionsBuilder()
    .AddConverter(new StringIntConverter())
    .AddConverter(new StringIntBoolConverter())
    .AddConverter(new StringDateTimeConverter("yyyyMMdd", "yyyy-MM-dd HH:mm"))
    .Build();

Why record converters live in the other package

SocialPlatformInfoJsonConverter and LanguageCodeInfoJsonConverter resolve a code to a registry record, so they would drag Lyo.Common.Metadata in behind them. Keeping them on the metadata side means a project that only wants the scalar converters does not acquire the catalogs, and neither package references the other.

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common.Core (direct, lyo)
  • Lyo.Exceptions (direct, lyo)
  • System.Text.Json 10.0.5 (direct, microsoft, netstandard2.0)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 (transitive, microsoft, netstandard2.0)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (18)

Showing the top 5 NuGet packages that depend on Lyo.Common.Json:

Package Downloads
Lyo.Query.Models

Query models for building and representing queries - QueryNode, QueryRequest, ConditionNode, SortBy, builders. Shared by Lyo.Query and Lyo.Api.

Lyo.Web.Components

Blazor components library for the Lyo web UI framework with MudBlazor integration.

Lyo.MessageQueue

Message queue service interface and base implementation for asynchronous messaging.

Lyo.Api

Core API library for building RESTful APIs with Entity Framework Core, caching, and mapping support.

Lyo.Config

Typed configuration definitions and per-entity bindings using flexible EntityRef references and JSON-backed values.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 429 9/9/2026