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 as a Cake Addin
#tool nuget:?package=JsonPathToModel&version=2.2.0
                    
Install 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 159 a month ago
2.1.0 143 a month ago
2.0.0 179 2 months ago
1.6.1 1,645 9 months ago
1.6.0 161 9 months ago
1.5.7 176 10 months ago 1.5.7 is deprecated because it has critical bugs.
1.5.6 455 10 months ago
1.5.5 155 10 months ago
1.5.4 127 10 months ago
1.5.3 202 10 months ago
1.5.2 136 10 months ago
1.5.1 131 10 months ago
1.5.0 130 10 months ago
1.4.0 206 10 months ago
1.3.2 235 10 months ago
1.3.1 252 9/2/2024
1.3.0 132 9/2/2024
1.2.6 132 8/29/2024
1.2.5 144 8/29/2024
1.2.4 127 8/27/2024
1.2.3 122 8/27/2024
1.2.2 129 8/26/2024
1.2.1 137 8/26/2024
1.2.0 176 8/25/2024 1.2.0 is deprecated because it has critical bugs.
1.1.0 136 8/20/2024
1.0.1 158 8/19/2024
1.0.0 156 8/19/2024