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: README.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,14 @@ This object is returned by the `Compile` function.
67
67
68
68
The JSONPath struct represents a reusable compiled JSONPath query which supports the `Query`, and `QueryString` functions as detailed above.
69
69
70
+
### Options
71
+
72
+
Part of the JSONPath object, Options allows you to specify what additional functionality, if any, that you want to enable while querying data.
73
+
74
+
You are able to enable index referencing support for maps for all tokens using `AllowMapReferenceByIndex` or use enable it for each token type individually.
75
+
76
+
You are able to enable index referencing support for strings for all tokens using `AllowStringReferenceByIndex` or use enable it for each token type individually.
77
+
70
78
## Supported Syntax
71
79
72
80
| syntax | name | example |
@@ -118,8 +126,6 @@ can also be used with the subscript syntax `$.store.book[*]`
118
126
119
127
allows for additional operators to be applied to the current object to retrieve a child element.
120
128
121
-
It is possible to use indexes to reference elements in a map, the order is determined by the keys in alphabetical order.
122
-
123
129
A negative value for an index is supported, resulting in the elements being counted in reverse, `-1` would represent the last item in the collection, `-2` the second last, and so on.
124
130
125
131
### Union
@@ -130,8 +136,6 @@ allows for a comma separated list of indices or keys to denote the elements to r
130
136
131
137
It is possible to use script expressions to define the union keys i.e. `$.store.book[0,(@.length-1)]` returns the first and last elements of the book collection.
132
138
133
-
It is possible to use indexes to reference elements in a map, the order is determined by the keys in alphabetical order.
134
-
135
139
A negative value for an index is supported, resulting in the elements being counted in reverse, `-1` would represent the last item in the collection, `-2` the second last, and so on.
136
140
137
141
### Range
@@ -185,11 +189,13 @@ the length token will allow you to return the length of an array, map, slice, or
185
189
186
190
If used with a map that has a key `length` it will return the corresponding value instead of the length of the map.
187
191
188
-
### Subscript, Union, and Range with strings
192
+
### Subscript, Union, and Range with maps and strings
193
+
194
+
Using the Compile() function, and modifying the JSONPath Options, it is possible to use a map or a string in place of an array with the subscript `[1]` union `[1,2,3]` and range `[0:3]` operations.
189
195
190
-
It is possible to use a string in place of an array with the subscript `[1]` union `[1,2,3]` and range `[0:3]` operations, and instead of returning an array of characters instead will return a substring.
196
+
For maps, the keys will be sorted into alphabetical order and they will be used to determine the index order. For example, if you had a map with strings `a`and `b`, regardless of the order, `a` would be the `0` index, and `b` the `1` index.
191
197
192
-
For example if you applied `[0:3]` to the string `string` it would return `str`.
198
+
For strings instead of returning an array of characters instead will return a substring. For example if you applied `[0:3]` to the string `string` it would return `str`.
0 commit comments