Skip to content

Commit 35f564d

Browse files
committed
Add readme for json path and use it as a package
1 parent 51c3e23 commit 35f564d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
```

0 commit comments

Comments
 (0)