File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ # JSON-path
2+
3+ JSON-path is a simple JSON path parser and evaluator for PHP. It is based on the JSONPath
4+ implementation in [ Goessner's JSONPath] ( http://goessner.net/articles/JsonPath/ ) .
5+ The code allows you to parse json paths and evaluate them on php objects. Which makes it a query language for
6+ php object structures.
7+
8+ It's propably not the fastest solution to query php objects, but as the paths are stored as plain strings, it's
9+ easy to use them in configuration files or databases. This makes is a good solution for tools that need to query
10+ a php object structure based on user input.
11+
12+ ## Installation
13+
14+ The recommended way to install JSON-path is through [ Composer] ( http://getcomposer.org ) .
15+
16+ ``` bash
17+ composer require phpdocumentor/json-path
18+ ```
19+
20+ ## Usage
21+
22+ ``` php
23+
24+ $parser = \phpDocumentor\JsonPath\Parser::createInstance();
25+ $query = $parser->parse('.store.book[*].author');
26+
27+ $executor = new \phpDocumentor\JsonPath\Executor();
28+ foreach ($executor->execute($query, $json) as $result) {
29+ var_dump($result);
30+ }
31+
32+ ```
You can’t perform that action at this time.
0 commit comments