JsonPathToModel 2.2.0

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

JsonPathToModel

Use JSONPath to navigate through .NET in-memory models

DI registration:

// program
...
    services.AddJsonPathToModel(options => 
                { 
                    options.OptimizeWithCodeEmitter = true;
                });
...

// constructor
public void MyService(IJsonPathModelNavigator navigator)
...

Usage:

var model = new SampleModel
{
    Id = "7",
    Name = "Gerry",
    Nested = new([new SampleNested { Id = "xyz", Name = "Pedro" }])
};

var navi = new JsonPathModelNavigator();

var resultSingle = navi.GetValue(model, "$.Id");
navi.GetValue(model, "$.Nested[0].Name");

var resultValues = navi.SelectValues(model, "$.Nested[*].Id");
navi.SelectValues(model, "$.Nested[*].Name");

navi.SetValue(model, "$.Nested[0].Name", "Abdula");

Model:

public class SampleModel
{
    public string Id { get; set; } 
    public string Name { get; set; }
    public List<SampleNested> Nested { get; set; } = [];
}

public class SampleNested
{
    public string Id { get; set; }
    public string Name { get; set; }
}

Release Notes

2.1.0+

  • added ExecutePrivate and ExecutePrivateStatic reflection extentions

2.0.0+

  • support of DateTimeOffset and DateOnly with tests
  • migrated to .NET9

1.6.0+

  • added HackingExtensions: WithHack, StealValue, StealString
  • upgraded System.Text.Json to 8.0.5

1.5.0+

  • added ModelStateExplorer to create JsonPath for type properties and fields
  • added support of fields
  • added support of nonpublics
  • added ModelSnapshot to extract model state into a serializable form

1.3.0 - 1.3.2

  • fixed few bugs
  • extended ReflectionHelper to support JsonIgnore

1.2.6

  • fixed a few bugs in tokenizer

1.2.5

  • fixed bug in auto-convert for SetValue, it works now when OptimizeWithCodeEmitter = true too

1.2.0 - 1.2.4:

  • Dramatically improved performance
  • Added DI services registration
  • Added Sigil Emitter optimizations for GetValue/SetValue simple expressions like '$.Person.FirstName'
  • Added Tokenizer for parsing JSONPath expressions
  • Added DateTime auto-convert for SetValue, it works only when OptimizeWithCodeEmitter = false
  • Refactored exceptions
  • → NETStandard2.1
  • Breaking changes: GetValue now throws exceptions, for Result<> pattern use GetValueResult

1.0.0 - 1.1.0:

  • Initital import from ProCodersPtyLtd/BlazorForms
Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on JsonPathToModel:

Package Downloads
MicroFlows

Use MicroFlows to implement Stateful workflows for microservices

MicroForms

Low-code form builder with advanced rule engine and microflows support for microservices

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.0 84 5/26/2025
2.1.0 82 5/25/2025
2.0.0 167 4/28/2025
1.6.1 1,640 10/14/2024
1.6.0 150 9/21/2024
1.5.7 163 9/16/2024 1.5.7 is deprecated because it has critical bugs.
1.5.6 445 9/16/2024
1.5.5 146 9/14/2024
1.5.4 117 9/14/2024
1.5.3 192 9/13/2024
1.5.2 118 9/13/2024
1.5.1 123 9/13/2024
1.5.0 122 9/13/2024
1.4.0 192 9/9/2024
1.3.2 224 9/6/2024
1.3.1 242 9/2/2024
1.3.0 120 9/2/2024
1.2.6 119 8/29/2024
1.2.5 124 8/29/2024
1.2.4 120 8/27/2024
1.2.3 113 8/27/2024
1.2.2 121 8/26/2024
1.2.1 124 8/26/2024
1.2.0 164 8/25/2024 1.2.0 is deprecated because it has critical bugs.
1.1.0 124 8/20/2024
1.0.1 145 8/19/2024
1.0.0 146 8/19/2024