Invex.Extensions.Json 0.3.0-rc.4

This is a prerelease version of Invex.Extensions.Json.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Invex.Extensions.Json --version 0.3.0-rc.4
                    
NuGet\Install-Package Invex.Extensions.Json -Version 0.3.0-rc.4
                    
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="Invex.Extensions.Json" Version="0.3.0-rc.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Invex.Extensions.Json" Version="0.3.0-rc.4" />
                    
Directory.Packages.props
<PackageReference Include="Invex.Extensions.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 Invex.Extensions.Json --version 0.3.0-rc.4
                    
#r "nuget: Invex.Extensions.Json, 0.3.0-rc.4"
                    
#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 Invex.Extensions.Json@0.3.0-rc.4
                    
#: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=Invex.Extensions.Json&version=0.3.0-rc.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Invex.Extensions.Json&version=0.3.0-rc.4&prerelease
                    
Install as a Cake Tool

Invex.Extensions.Json

Lightweight, allocation-conscious utilities for flattening, unflattening, and updating System.Text.Json node trees (JsonNode / JsonObject / JsonArray) using human-readable path notation such as user:address:city.

Ideal for configuration manipulation, ETL pipelines, diffing/patching JSON documents, and round-tripping JSON to flat key/value stores (e.g., IConfiguration-style providers).

License: MIT

Features

  • 🔹 Flatten any JsonNode tree into a flat dictionary of path → value pairs
  • 🔹 Unflatten flattened pairs back into a hierarchical JsonObject
  • 🔹 Replace values at one or many paths — including inside arrays — without creating structure you didn't ask for
  • 🔹 JsonObject extension members (ToFlattenedJsonObject, ToFlattenedDictionary, ToUnflattenedJsonObject, HasNestedObjects) with full type preservation and sparse-array padding
  • 🔹 Configurable, multi-character separators (default :)
  • 🔹 No reflection, no regex on hot paths, minimal allocations
  • 🔹 Targets net10.0, net9.0, net8.0, and netstandard2.0

Installation

dotnet add package Invex.Extensions.Json

Quick start

using System.Text.Json.Nodes;
using Invex.Extensions.Json;

var json = JsonNode.Parse("""
{
  "user": {
    "name": "John",
    "tags": ["admin", "user"]
  }
}
""")!;

// Flatten to path/value pairs (bracketed array indices)
IDictionary<string, string?> flat = JsonExtensions.Flatten(json);
// ["user:name"]      = "John"
// ["user:tags:[0]"]  = "admin"
// ["user:tags:[1]"]  = "user"

// Rebuild the tree
JsonObject rebuilt = JsonExtensions.Unflatten(flat);

// Update values in place (bare numeric array indices)
rebuilt.ReplaceValues(new Dictionary<string, string?>
{
    ["user:name"]    = "Jane",
    ["user:tags:1"]  = "editor",
});

Or use the type-preserving JsonObject extension members:

var obj = JsonNode.Parse("""{ "a": { "n": 42, "b": [true, null] } }""")!.AsObject();

JsonObject flatObj = obj.ToFlattenedJsonObject();   // values keep their JSON types
JsonObject roundTrip = flatObj.ToUnflattenedJsonObject();

Documentation

Topic Description
Getting started Installation, namespaces, and a guided tour
Path notation The two path conventions and when each applies
Flattening & unflattening JsonExtensions.Flatten / Unflatten in depth
JsonObject extension members ToFlattenedJsonObject, ToFlattenedDictionary, ToUnflattenedJsonObject, HasNestedObjects
Replacing values ReplaceValue / ReplaceValues semantics and fallbacks
API reference Generated API documentation

Choosing the right API

There are two complementary API surfaces — pick based on whether you need type fidelity:

JsonExtensions (static) JsonObject extension members
Array index notation Bracketed: users:[0]:name Bare numeric: users:0:name
Value representation Strings only Original JSON types preserved
Sparse array indices Applied in append order Padded with nulls
Flatten input Any JsonNode JsonObject
Best for Key/value stores, config providers Lossless round-tripping

See Path notation for the full comparison.

License

Licensed under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0-rc.4 45 11/20/2026
1.3.0-rc.2 58 11/13/2026
1.2.0 86 11/11/2026
1.2.0-rc.12 53 11/11/2026
1.2.0-rc.2 66 10/30/2026
1.1.0 100 10/22/2026
1.1.0-rc.6 62 10/22/2026
1.1.0-rc.4 68 10/22/2026
1.1.0-rc.2 62 10/16/2026
1.0.0 102 10/15/2026
0.4.0-rc.30 61 10/15/2026
0.4.0-rc.28 62 10/14/2026
0.4.0-rc.26 63 10/14/2026
0.4.0-rc.24 55 10/14/2026
0.4.0-rc.22 55 10/14/2026
0.4.0-rc.20 68 10/14/2026
0.4.0-rc.16 60 10/13/2026
0.4.0-rc.10 71 9/11/2026
0.4.0-rc.8 80 8/28/2026
0.3.0-rc.4 82 7/24/2026
Loading failed