Soenneker.Json.OptionsCollection
4.0.1287
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Json.OptionsCollection --version 4.0.1287
NuGet\Install-Package Soenneker.Json.OptionsCollection -Version 4.0.1287
<PackageReference Include="Soenneker.Json.OptionsCollection" Version="4.0.1287" />
<PackageVersion Include="Soenneker.Json.OptionsCollection" Version="4.0.1287" />
<PackageReference Include="Soenneker.Json.OptionsCollection" />
paket add Soenneker.Json.OptionsCollection --version 4.0.1287
#r "nuget: Soenneker.Json.OptionsCollection, 4.0.1287"
#:package Soenneker.Json.OptionsCollection@4.0.1287
#addin nuget:?package=Soenneker.Json.OptionsCollection&version=4.0.1287
#tool nuget:?package=Soenneker.Json.OptionsCollection&version=4.0.1287
Soenneker.Json.OptionsCollection
Common serializer profiles for System.Text.Json and Newtonsoft.Json.
Install
dotnet add package Soenneker.Json.OptionsCollection
System.Text.Json profiles
using System.Text.Json;
using Soenneker.Json.OptionsCollection;
string apiJson = JsonSerializer.Serialize(
response,
JsonOptionsCollection.WebOptions);
string readableJson = JsonSerializer.Serialize(
response,
JsonOptionsCollection.PrettySafeOptions);
| Profile | Naming/defaults | Indented | Enum strings | Comment reads | Encoder |
|---|---|---|---|---|---|
GeneralOptions |
General | No | No | Skip | Default |
WebOptions |
Web | No | Yes | Skip | Default |
PrettyOptions |
General | Yes | Yes | Disallow | Relaxed |
PrettySafeOptions |
General | Yes | Yes | Disallow | Default |
All four profiles omit null properties and are shared, read-only instances. Clone one before customization:
var custom = new JsonSerializerOptions(
JsonOptionsCollection.WebOptions)
{
WriteIndented = true
};
PrettyOptions uses UnsafeRelaxedJsonEscaping, which leaves characters such as <, >, and & less escaped. Do not embed its output directly into HTML or a script context. Use PrettySafeOptions when output crosses a trust boundary.
Select a profile by JsonOptionType
JsonSerializerOptions options =
JsonOptionsCollection.GetOptionsFromType(optionType);
GeneralValue, PrettyValue, and PrettySafeValue select their matching profiles. A null or unrecognized value falls back to WebOptions.
Newtonsoft.Json
using Newtonsoft.Json;
JsonSerializerSettings settings = JsonOptionsCollection.Newtonsoft;
settings.DateParseHandling = DateParseHandling.None;
string json = JsonConvert.SerializeObject(value, settings);
Each access returns a new settings object, so caller customization cannot alter another serializer's behavior. The defaults omit null properties, write enums as strings, and leave CheckAdditionalContent disabled.
| Product | Versions 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. |
-
net10.0
- Newtonsoft.Json (>= 13.0.4)
- Soenneker.Enums.JsonOptions (>= 4.0.741)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Soenneker.Json.OptionsCollection:
| Package | Downloads |
|---|---|
|
Soenneker.Utils.Json
Serializes, deserializes, validates, formats, and writes JSON with System.Text.Json. |
|
|
Soenneker.Cosmos.Serializer
A fast, lightweight JSON (de)serializer for Azure Cosmos DB |
|
|
Soenneker.Extensions.JsonElements
A collection of helpful JsonElement extension methods |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1314 | 32 | 10/15/2026 |
| 4.0.1313 | 45 | 10/14/2026 |
| 4.0.1312 | 396 | 10/14/2026 |
| 4.0.1310 | 2,159 | 10/14/2026 |
| 4.0.1309 | 765 | 10/14/2026 |
| 4.0.1308 | 58 | 10/14/2026 |
| 4.0.1302 | 873 | 10/13/2026 |
| 4.0.1301 | 2,226 | 10/12/2026 |
| 4.0.1299 | 1,020 | 10/12/2026 |
| 4.0.1298 | 9,583 | 10/11/2026 |
| 4.0.1297 | 1,023 | 10/11/2026 |
| 4.0.1296 | 84 | 10/11/2026 |
| 4.0.1295 | 41,841 | 9/30/2026 |
| 4.0.1294 | 841 | 9/30/2026 |
| 4.0.1293 | 5,352 | 9/29/2026 |
| 4.0.1292 | 19,304 | 9/25/2026 |
| 4.0.1291 | 5,811 | 9/25/2026 |
| 4.0.1290 | 328 | 9/24/2026 |
| 4.0.1289 | 29,263 | 9/15/2026 |
| 4.0.1287 | 27,213 | 9/12/2026 |
Update dependency Soenneker.Enums.JsonOptions to 4.0.741 (#1963)