You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _docs/path/basics.md
+9-7
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,17 @@
1
1
---
2
2
layout: page
3
3
title: JsonPath.Net Basics
4
-
bookmark: JsonPath.Net
4
+
md_title: _JsonPath.Net_ Basics
5
+
bookmark: JSON Path
6
+
permalink: /path/:title/
5
7
icon: fas fa-tag
6
8
order: "2.1"
7
9
---
8
-
JSON Path is a query language for JSON documents inspired by what XPath provides for XML documents. It was [originally proposed](https://goessner.net/articles/JsonPath/) by Matt Goessner, and now a [specification](https://github.com/jsonpath-standard/internet-draft) is in progress.
10
+
JSON Path is a query language for JSON documents inspired by what XPath provides for XML documents. It was [originally proposed](https://goessner.net/articles/JsonPath/) by Matt Goëssner, and now a [specification](https://github.com/jsonpath-standard/internet-draft) is in progress.
9
11
10
12
Version 0.4.x is aligned with the specification as of the end of Feb 2023, including support for functions (recently merged) and arithmetic operations in expressions (not part of the spec yet).
11
13
12
-
# Syntax {#path-syntax}
14
+
##Syntax {#path-syntax}
13
15
14
16
A path consists of start indicator followed by a series of segments, chained one after another. Each segment contains one or more selectors. Each selector takes in a collection of JSON nodes and produces a collection of JSON nodes (called a "nodelist") based on their function. The output of the segment is the collective output of all of that segment's selectors. Each segment takes as input the output of the previous selector.
15
17
@@ -32,7 +34,7 @@ In addition to the above, there are a few shorthand options for some special cas
32
34
-`..['foo']` may be rewritten as `..foo`
33
35
-`..[*]` may be rewritten as `..*`
34
36
35
-
## Query Expressions {#path-expressions}
37
+
###Query Expressions {#path-expressions}
36
38
37
39
Filter selectors take an expression. This expression uses a single variable, which is a JSON node as described above. The node is denoted by `@` and any valid JSON Path can follow it. The `@` is a stand-in for the `$` from above and acts as the root of the local value.
38
40
@@ -65,7 +67,7 @@ Expressions support the following operations:
65
67
> Arithmetic operations are not part of the specification (yet), and cannot be expected to work in other JSON Path implementations.
66
68
{: .prompt-info }
67
69
68
-
### Functions {#path-functions}
70
+
####Functions {#path-functions}
69
71
70
72
There is also support for functions within query expressions, which works as an extension point to add your own custom logic.
71
73
@@ -109,7 +111,7 @@ Now that your function class is created, all that's left is to register it:
109
111
FunctionRepository.Register(newMyCustomFunc());
110
112
```
111
113
112
-
# In Code {#path-in-code}
114
+
##In Code {#path-in-code}
113
115
114
116
To obtain an instance of a JSON Path, you'll need to parse it from a string.
115
117
@@ -137,7 +139,7 @@ This will return a results object that contains the resulting nodelist or an err
137
139
138
140
A node contains both the value that was found and the location in the instance _where_ it was found. The location is always represented using the "canonical," bracketed format.
139
141
140
-
# Adherence to the Proposed Specification {#path-spec}
142
+
##Adherence to the Proposed Specification {#path-spec}
141
143
142
144
As the specification is still under authorship, there are features present in traditional JSON Path that haven't been properly described yet. For these features, this library has been configured to mimic the consensus behaviors of other libraries as determined by the [JSON Path Comparison](https://cburgmer.github.io/json-path-comparison/) project.
[#420](https://github.com/gregsdennis/json-everything/issues/404) - `<=` not working for the "between" case. Thanks to [@alexkharuk](https://github.com/alexkharuk) for finding and fixing this issue.
@@ -119,4 +125,4 @@ Signed the DLL for strong name compatibility.
[#397](https://github.com/gregsdennis/json-everything/issues/397) - Fixed an issue where `replace` needs to check that the target location exists before proceeding with the `add` portion of its operation.
[#408](https://github.com/gregsdennis/json-everything/issues/408) - Fixed an issue where an empty string segment fails for array values. Thanks to [@mbj2011](https://github.com/mbj2011) for finding and reporting this.
[Powershell PR #19610](https://github.com/PowerShell/PowerShell/pull/19610) - Support for \*nix-based file paths caused an error in setting the base URI that resulted in the first folder in the path being interpreted as the URI host.
0 commit comments