Linger.Json
2.0.0-preview.1
dotnet add package Linger.Json --version 2.0.0-preview.1
NuGet\Install-Package Linger.Json -Version 2.0.0-preview.1
<PackageReference Include="Linger.Json" Version="2.0.0-preview.1" />
<PackageVersion Include="Linger.Json" Version="2.0.0-preview.1" />
<PackageReference Include="Linger.Json" />
paket add Linger.Json --version 2.0.0-preview.1
#r "nuget: Linger.Json, 2.0.0-preview.1"
#:package Linger.Json@2.0.0-preview.1
#addin nuget:?package=Linger.Json&version=2.0.0-preview.1&prerelease
#tool nuget:?package=Linger.Json&version=2.0.0-preview.1&prerelease
Linger.Json
Migration notes for 2.0 are documented in the Linger.Json migration guide; see the Linger migration guide for other packages.
Linger.Json contains the optional JSON support that was previously part of Linger.Utils. It provides System.Text.Json converters, DataTable conversion extensions, and reusable JsonSerializerOptions factories.
Installation
dotnet add package Linger.Json
For the 2.0 package split, add a reference to Linger.Json wherever the following APIs are used: JsonDefaults, DateTimeConverter, DateTimeNullConverter, DataTableJsonConverter, DataSetConverter, JsonStringConverter, string.ToDataTable(), DataTable.ToJsonString(), or JsonElement.JsonElementToDataTable().
DataTable JSON Extensions
using Linger.Extensions;
using Linger.Extensions.Core;
using Linger.Extensions.Data;
using System.Text.Json;
DataTable? table = "[{\"Name\":\"Ada\",\"Age\":37}]".ToDataTable();
string json = table.ToJsonString();
using var document = JsonDocument.Parse(json);
DataTable inferredTable = document.RootElement.JsonElementToDataTable();
JSON Serialization Configuration
JsonDefaults provides unified JSON serialization configuration for HTTP clients and ASP.NET Core WebAPI applications.
Overview
JsonDefaults provides centralized JSON serialization options that follow the "Be conservative in what you send, be liberal in what you accept" principle:
- Response/Input Options (CreateResponseOptions): Liberal configuration for deserializing API responses
- Request/Output Options (CreateRequestOptions): Conservative configuration for serializing API requests
- WebAPI Configuration (ApplyDefaultConfiguration): Applies optimized configuration to existing options, balancing input tolerance and output optimization
Usage in ASP.NET Core WebAPI
For Controllers (MVC/WebAPI)
Add this to your Program.cs or Startup.cs:
using Linger.Json;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers()
.AddJsonOptions(options =>
JsonDefaults.ApplyDefaultConfiguration(options.JsonSerializerOptions));
var app = builder.Build();
For Minimal API
using Linger.Json;
var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options =>
JsonDefaults.ApplyDefaultConfiguration(options.SerializerOptions));
var app = builder.Build();
Manual Configuration
If you need to customize further:
using Linger.Json;
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
JsonDefaults.ApplyDefaultConfiguration(options.JsonSerializerOptions);
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
});
Configure JsonSerializerOptions Directly
using Linger.Json;
var jsonOptions = new JsonSerializerOptions();
JsonDefaults.ApplyDefaultConfiguration(jsonOptions);
var responseOptions = JsonDefaults.CreateResponseOptions();
var requestOptions = JsonDefaults.CreateRequestOptions();
Features
Response Options - CreateResponseOptions() (Liberal, for receiving)
- Accepts number strings ("123" as 123)
- Handles reference cycles
- Preserves null values
- Custom date/time converters
- DataTable support
- Camel case properties (Web defaults)
Request Options - CreateRequestOptions() (Conservative, for sending)
- Standard JSON format (numbers without quotes)
- Omits null values (reduces payload size)
- Custom date/time converters
- Camel case properties (Web defaults)
- Only includes necessary converters (more lightweight)
WebAPI Configuration - ApplyDefaultConfiguration() (Balanced, for WebAPI)
- Accepts number strings (input tolerance)
- Handles reference cycles
- Omits null values (output optimization)
- Custom date/time converters
- DataTable support
- Camel case properties (Web defaults)
Benefits
- Consistency: Same JSON behavior across HTTP clients and WebAPI
- Maintainability: Single source of truth for JSON configuration
- Best Practices: Follows "strict output, lenient input" principle
- Interoperability: Handles common API variations (number strings, etc.)
Built-in Converters
The following custom converters are included in the configuration:
- DateTimeConverter: Handles DateTime serialization/deserialization
- DateTimeNullConverter: Handles nullable DateTime
- DataTableJsonConverter: Converts between DataTable and JSON
Related Types
- JsonDefaults - JSON default configuration utility class
- DateTimeConverter - DateTime serialization converter
- DateTimeNullConverter - Nullable DateTime converter
- DataTableJsonConverter - DataTable serialization converter
- StandardHttpClient - standard HTTP client implementation that uses these options
| 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 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. |
| .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
- System.Data.DataSetExtensions (>= 4.5.0)
- System.Text.Json (>= 10.0.10)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Linger.Json:
| Package | Downloads |
|---|---|
|
Linger.HttpClient.Standard
A lightweight implementation of Linger.HttpClient.Contracts using standard .NET HttpClient. Provides typed response parsing, per-request headers, and streaming file transfers. Seamlessly integrates with .NET's HttpClientFactory for optimal connection management. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.1 | 49 | 8/29/2026 |