Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The JsonCons.Net libraries complement the System.Text.Json namespace with support for JSON Pointer, JSON Patch, JSON Merge Patch, JSONPath, and JMESPath.

License

NotificationsYou must be signed in to change notification settings

danielaparker/JsonCons.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonCons.UtilitiesJsonCons.JsonPathJsonCons.JmesPath
NuGet version
NuGet version
NuGet version
NuGet version
NuGet version
NuGet version

The JsonCons.Net libraries include classes that complement the functionality of theSystem.Text.Json namespace.The libraries target .Net Standard 2.1.

The JsonCons.Net libraries offer support for:

JSONPath and JMESPath

JSONPath allows you to select from aJsonDocumenta list ofJsonElement instancesthat belong to it. JMESPath allows you to transform aJsonDocumentinto anotherJsonDocument.

For example, consider the JSON data

string jsonString = @"{""Data"":[        {""KeyOfInterest"":true,""AnotherKey"":true        },        {""KeyOfInterest"":false,""AnotherKey"":true        },        {""KeyOfInterest"":true,""AnotherKey"":true        }]}";using JsonDocument doc = JsonDocument.Parse(jsonString);

JSONPath allows you to select theKeyOfInterest values like this:

stringpath="$.Data[*].KeyOfInterest";IList<JsonElement>results=JsonSelector.Select(doc.RootElement,path);

and the union ofKeyOfInterest andAnotherKey values like this:

stringpath="$.Data[*]['KeyOfInterest', 'AnotherKey']";IList<JsonElement>results=JsonSelector.Select(doc.RootElement,path);

The first query produces

[true,false,true]

and the second

[true,true,false,true,true,true]

Note that each element in the result -true,false,true - corresponds to an elementat a specific location in the original JSON document. This is a feature of JSONPath.

JMESPath allows you to select theKeyOfInterest values like this:

stringexpr=Data[*].KeyOfInterest;JsonDocumentresult=JsonTransformer.Transform(doc.RootElement,expr);

and a multiselect hash ofKeyOfInterest andAnotherKey values like this:

stringexpr="Data[*].{\"Key of Interest\" : KeyOfInterest,\"Another Key\": AnotherKey}";JsonDocumentresult=JsonTransformer.Transform(doc.RootElement,expr);

The first query produces

[true,false,true]

and the second

[  {"Key of Interest":true,"Another Key":true  },  {"Key of Interest":false,"Another Key":true  },  {"Key of Interest":true,"Another Key":true  }]

JMESPath, unlike JSONPath, can create new elements that are not in the original document.JMESPath can transform, while JsonPath can only select.

Documentation and Examples

Reference documentation is availablehere

Code examples may be found at:

JSON Pointer examples

JSON Patch examples

JSON Merge Patch examples

JSONPath examples

JMESPath examples

About

The JsonCons.Net libraries complement the System.Text.Json namespace with support for JSON Pointer, JSON Patch, JSON Merge Patch, JSONPath, and JMESPath.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp