Soenneker.Utils.Json 11.0.2779

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.Json

Serializes, deserializes, validates, formats, and safely writes JSON with System.Text.Json.

Installation

dotnet add package Soenneker.Utils.Json

Quick start

Serialization, deserialization, validation, and formatting are static operations on JsonUtil:

using Soenneker.Utils.Json;

string? json = JsonUtil.Serialize(new { Id = 42, Name = "example" });
Document? document = JsonUtil.Deserialize<Document>(json!);

if (!JsonUtil.TryDeserialize<Document>(utf8Json, out Document? parsed))
{
    // The input was empty, invalid, or represented JSON null.
}

Serialization uses System.Text.Json with JsonOptionsCollection.WebOptions by default. Pass a JsonTypeInfo<T> to use source-generated System.Text.Json metadata.

Register the service only when using the instance-based WritePretty file operation:

using Soenneker.Utils.Json.Registrars;

services.AddJsonUtilAsSingleton();

Then inject IJsonUtil and call WritePretty.

Common operations

  • Deserialize() - Deserializes strings, UTF-8 data, streams, or HTTP response content. Empty strings and byte spans return the default value.
  • Serialize() - Returns null for a null object; otherwise uses WebOptions unless another options profile is selected.
  • SerializeToElement() - Serializes the value into a nullable JsonElement using the requested options.
  • SerializeToStream() - Serializes the object into the given stream using System.Text.Json.
  • SerializeToUtf8Bytes() - Serializes an object to a UTF-8 encoded byte array using System.Text.Json.
  • DeserializeFromFile() - Reads a file asynchronously and deserializes its JSON to T; JSON null yields null.
  • SerializeToFile() - Serializes to a temporary sibling file and replaces the destination only after serialization succeeds. A null object leaves the destination unchanged.
  • TryDeserialize() - Returns false for empty input, invalid JSON, or a deserialized null value. Supports optional source-generated metadata.
  • IsJsonValid() - Returns true only when the entire input is syntactically valid JSON; invalid input returns false and can be logged.
  • Format() - Parses and pretty-prints JSON, optionally forcing Windows CRLF line endings.
  • WritePretty() - Reads a JSON file, formats it, and writes the result to the destination path.

The async deserialization overloads that accept a logger return the default value after other read or deserialization failures, but requested cancellation is propagated. The stream overloads leave caller-owned streams open.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (35)

Showing the top 5 NuGet packages that depend on Soenneker.Utils.Json:

Package Downloads
Soenneker.Extensions.Object

A collection of helpful Object extension methods

Soenneker.Redis.Util

The general purpose utility library leveraging Redis for all of your caching needs

Soenneker.Cosmos.Repository

A data persistence abstraction layer for Cosmos DB

Soenneker.Extensions.HttpResponseMessage

A collection of helpful HttpResponseMessage extension methods

Soenneker.Utils.String

A utility library for useful String operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.2779 12,081 11/3/2026
11.0.2778 2,153 11/3/2026
11.0.2777 1,923 11/3/2026
11.0.2776 1,370 11/3/2026
11.0.2774 1,015 11/3/2026
11.0.2773 3,616 11/3/2026
11.0.2771 1,705 11/2/2026
11.0.2770 16,431 10/29/2026
11.0.2769 12,595 10/27/2026
11.0.2766 1,637 10/26/2026
11.0.2764 2,013 10/26/2026
11.0.2763 833 10/26/2026
11.0.2762 1,451 10/26/2026
11.0.2761 395 10/26/2026
11.0.2760 489 10/26/2026
11.0.2758 325 10/26/2026
4.0.2757 26,766 10/15/2026
4.0.2756 1,676 10/15/2026
4.0.2755 532 10/15/2026
4.0.2753 2,988 10/14/2026
Loading failed

Updated Soenneker.Utils.File to 11.0.2333