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

JsonDocumentPath is a class library to extract values from JSON (System.Text.Json.JsonDocument) with single line expressions (JsonPath)

License

Notifications You must be signed in to change notification settings

yingpanwang/JsonPathQuery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

36 Commits

Repository files navigation

JsonDocumentPath

JsonDocumentPath is a class library to extract values from JSON (System.Text.Json.JsonDocument) with single line expressions

The JsonPath parser is based on the Newtonsoft.Json

NuGet Package

How to use it

 string json = @"{
 ""persons"": [
 {
 ""name"" : ""John"",
 ""age"": ""26""
 },
 {
 ""name"" : ""Jane"",
 ""age"": ""2""
 }
 ]
 }";
var models = JsonDocument.Parse(json);
var results = models.SelectElements("$.persons[?(@.age > 3)]").ToList();

Implementation

Because JsonDocumentPath is using the same Json.net strategic for parsing and evaluation the following is a list of pieces were already implemented:

Filters:

  • ArrayIndexFilter
  • ArrayMultipleIndexFilter
  • ArraySliceFilter
  • FieldFilter
  • FieldMultipleFilter
  • QueryFilter
  • QueryScanFilter
  • RootFilter
  • ScanFilter
  • ScanMultipleFilter

Unit Test:

  • JPathParseTests
  • QueryExpressionTests
  • JPathExecuteTests
  • JsonNodeParseTests
  • JsonNodePathExecuteTests
  • JsonNodeQueryExpressionTests
  • JsonNodeRefTests

About

JsonDocumentPath is a class library to extract values from JSON (System.Text.Json.JsonDocument) with single line expressions (JsonPath)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%

AltStyle によって変換されたページ (->オリジナル) /