Soenneker.Json.OptionsCollection
4.0.1282
Prefix Reserved
dotnet add package Soenneker.Json.OptionsCollection --version 4.0.1282
NuGet\Install-Package Soenneker.Json.OptionsCollection -Version 4.0.1282
<PackageReference Include="Soenneker.Json.OptionsCollection" Version="4.0.1282" />
<PackageVersion Include="Soenneker.Json.OptionsCollection" Version="4.0.1282" />
<PackageReference Include="Soenneker.Json.OptionsCollection" />
paket add Soenneker.Json.OptionsCollection --version 4.0.1282
#r "nuget: Soenneker.Json.OptionsCollection, 4.0.1282"
#:package Soenneker.Json.OptionsCollection@4.0.1282
#addin nuget:?package=Soenneker.Json.OptionsCollection&version=4.0.1282
#tool nuget:?package=Soenneker.Json.OptionsCollection&version=4.0.1282
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.737)
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 or Newtonsoft.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.1282 | 444 | 8/30/2026 |
| 4.0.1281 | 89 | 8/30/2026 |
| 4.0.1280 | 356 | 8/30/2026 |
| 4.0.1279 | 40 | 8/30/2026 |
| 4.0.1278 | 3,291 | 8/29/2026 |
| 4.0.1277 | 36 | 8/29/2026 |
| 4.0.1276 | 26,576 | 8/21/2026 |
| 4.0.1275 | 13,578 | 8/18/2026 |
| 4.0.1274 | 141 | 8/18/2026 |
| 4.0.1273 | 40,458 | 8/7/2026 |
| 4.0.1272 | 18,016 | 7/28/2026 |
| 4.0.1271 | 3,749 | 7/28/2026 |
| 4.0.1270 | 3,641 | 7/27/2026 |
| 4.0.1269 | 29,106 | 7/18/2026 |
| 4.0.1267 | 52,253 | 7/3/2026 |
| 4.0.1266 | 18,658 | 6/19/2026 |
| 4.0.1265 | 8,524 | 6/19/2026 |
| 4.0.1264 | 1,016 | 6/18/2026 |
| 4.0.1263 | 59,033 | 6/6/2026 |
| 4.0.1262 | 127 | 6/5/2026 |
Update dependency Soenneker.Enums.JsonOptions to 4.0.737 (#1938)