Lyo.Json
3.0.0
dotnet add package Lyo.Json --version 3.0.0
NuGet\Install-Package Lyo.Json -Version 3.0.0
<PackageReference Include="Lyo.Json" Version="3.0.0" />
<PackageVersion Include="Lyo.Json" Version="3.0.0" />
<PackageReference Include="Lyo.Json" />
paket add Lyo.Json --version 3.0.0
#r "nuget: Lyo.Json, 3.0.0"
#:package Lyo.Json@3.0.0
#addin nuget:?package=Lyo.Json&version=3.0.0
#tool nuget:?package=Lyo.Json&version=3.0.0
Lyo.Json
The JSON contract Lyo APIs, clients, and message-queue envelopes serialize against lives in Lyo.Json: camelCase properties, case-insensitive reads, nulls omitted on write, camelCase string enums, and ReferenceHandler.IgnoreCycles so EF-shaped graphs serialize.
JsonService.Default is that contract. Pass a JsonOptions instance or new JsonService (o ⇒ { ... }) to change naming, enums, number handling, write omission, encoding, and comments. Pass a JsonSerializerOptions instance and it is copied and used as-is. One instance is safe for concurrent parse and export. Options are fixed after construction.
Byte methods take an optional Encoding. A missing argument uses the service encoding (UTF-8 without a BOM). A character span is already decoded. File and stream reads detect a BOM. Async twins and NDJSON streaming exist on net10.0.
Converters under JsonConverters/ stay unregistered until UseStringScalarConverters is set. Add them for one integration through LyoJsonSerializerOptionsBuilder. Namespaces match the package: options are Lyo.Json.LyoJsonSerializerOptions and converters live in Lyo.Json.JsonConverters.
Features
- JsonService.Default, new JsonService (JsonOptions), new JsonService (configure), or new JsonService (JsonSerializerOptions) for camelCase, snake_case, kebab-case, or PascalCase, string or numeric enums, and write omission of nulls, defaults, empty strings, and empty collections.
Orderis Defined (declaration order), Alphabetical, or Specified. Specified uses[MemberOrder]andOrderNames. Defined does not sort.ExportFormattedToJsonStringwrites formatter fields in dictionary order.ExportColumnsToJsonStringwrites a header-to-property map in that same order.Orderdoes not reorder either list.- Optional Encoding on ParseBytes, Parse (ReadOnlySpan<byte>), ExportToJsonBytes, and TryExport. UTF-8 uses the System.Text.Json span APIs.
- NDJSON: ParseNdjsonFile, ParseNdjsonStream, ParseNdjsonString, and ParseNdjsonBytes, plus net10 IAsyncEnumerable for file and stream. Export writes one compact value per line.
- LyoJsonSerializerOptions.Create, Create (configure), and ApplyTo for the HTTP contract. LyoJsonSerializerOptionsBuilder adds converters.
- A top-level JSON array binds List<T> or T[].
- JsonNodeGraph converts a JsonNode to dictionaries, lists, and scalars so YAML, XML, and TOML share this contract.
- ObjectJsonConverter and the string scalar converters stay opt-in.
Examples
Parse and export a person
using Lyo.Json;
var person = JsonService.Default.ParseString<Person>("""{"givenName":"Ada"}""");
var snake = new JsonService(o => o.Naming = DocumentNaming.SnakeCase);
string text = snake.ExportToJsonString(person);
Serialize against the shared contract
using Lyo.Json;
var options = LyoJsonSerializerOptions.Create();
var json = JsonSerializer.Serialize(dto, options);
var back = JsonSerializer.Deserialize<MyDto>(json, options);
ASP.NET export
When an ASP.NET JsonOptions instance is registered, construct new JsonService (serializerOptions: aspNetSerializerOptions). The service copies those options and does not apply JsonOptions on top, and it does not mutate the host instance. ConfigureHttpJsonOptions can copy the same defaults with LyoJsonSerializerOptions.ApplyTo.
Why record converters live in metadata
SocialPlatformInfoJsonConverter and LanguageCodeInfoJsonConverter resolve a code to a registry record, so they stay in Lyo.Common.Metadata. A project that only wants the scalar converters does not acquire the catalogs.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common.Core(direct, lyo)Lyo.Exceptions(direct, lyo)System.Text.Encoding.CodePages10.0.5(direct, microsoft)System.Text.Json10.0.5(direct, microsoft, netstandard2.0)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)System.Memory4.6.3(transitive, microsoft, netstandard2.0)
| Product | Versions 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. |
-
.NETStandard 2.0
- Lyo.Common.Core (>= 3.0.0)
- Lyo.DataTable.Models (>= 3.0.0)
- Lyo.Exceptions (>= 3.0.0)
- Lyo.Result (>= 3.0.0)
- System.Text.Encoding.CodePages (>= 10.0.5)
- System.Text.Json (>= 10.0.5)
-
net10.0
- Lyo.Common.Core (>= 3.0.0)
- Lyo.DataTable.Models (>= 3.0.0)
- Lyo.Exceptions (>= 3.0.0)
- Lyo.Result (>= 3.0.0)
NuGet packages (32)
Showing the top 5 NuGet packages that depend on Lyo.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 |
|---|---|---|
| 3.0.0 | 1,425 | 10/23/2026 |