Skip to content

Commit 54b4018

Browse files
committed
Added support for other filter expression operators + tests
1 parent 3fcea4f commit 54b4018

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,17 @@ done
201201
-f test/valid/goessner.net.expanded.json \
202202
-i '$..book[?(@.title==".*Book 1.*")].title'
203203

204-
# The following do not work yet (TODO)
205-
./JSONPath.sh \
204+
# All books with a price less than or equal to 4.20
205+
# Show both the title and the price and output in
206+
# JSON format but without redundant path elements.
207+
./JSONPath.sh -j -u \
206208
-f test/valid/goessner.net.expanded.json \
207-
'$.store.book[(@.length-1)].title'
209+
'$.store.book[?(@.price<4.20)].[title,price]'
210+
211+
# The following does not work yet (TODO)
208212
./JSONPath.sh \
209213
-f test/valid/goessner.net.expanded.json \
210-
'$.store.book[?(@.price < 10)].title'
214+
'$.store.book[(@.length-1)].title'
211215
```
212216

213217
## JSONPath patterns and extensions
@@ -224,13 +228,9 @@ done
224228
| [] | Y | subscript operator. |
225229
| [,] | Y | node sets. |
226230
| ```[start:end:step]``` | Y | array slice operator. |
227-
| ?() | Y | applies a filter (script) expressions (see note) |
231+
| ?() | Y | applies a filter (script) expressions |
228232
| () | Y | script expression, using the underlying script engine. |
229233

230-
NOTE: For filter expressions only the equality operator, '==', is implemented.
231-
232-
*TODO*: >=, >, <=, and <
233-
234234
### Searching for things
235235

236236
"regex"
@@ -360,7 +360,6 @@ $ ./JSONPath.sh -f test/valid/goessner.net.expanded.json \
360360
## Limitations (todo)
361361

362362
* Only one filter expression, '?(@', per query.
363-
* Only equality operator, '==' and '=', is implemented for filter expressions.
364363

365364
## License
366365

0 commit comments

Comments
 (0)