JsonPathToModel 2.0.0

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

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

1.6.0+

  • added HackingExtensions: WithHack, StealValue, StealString

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. 
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.0.0 157 4/28/2025
1.6.1 1,592 10/14/2024
1.6.0 146 9/21/2024
1.5.7 159 9/16/2024 1.5.7 is deprecated because it has critical bugs.
1.5.6 441 9/16/2024
1.5.5 142 9/14/2024
1.5.4 113 9/14/2024
1.5.3 188 9/13/2024
1.5.2 114 9/13/2024
1.5.1 119 9/13/2024
1.5.0 118 9/13/2024
1.4.0 187 9/9/2024
1.3.2 220 9/6/2024
1.3.1 238 9/2/2024
1.3.0 115 9/2/2024
1.2.6 115 8/29/2024
1.2.5 120 8/29/2024
1.2.4 116 8/27/2024
1.2.3 109 8/27/2024
1.2.2 117 8/26/2024
1.2.1 120 8/26/2024
1.2.0 160 8/25/2024 1.2.0 is deprecated because it has critical bugs.
1.1.0 119 8/20/2024
1.0.1 141 8/19/2024
1.0.0 142 8/19/2024