From 35f564d8a7435224d1d677be05a68afc5d2e9804 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Fri, 24 May 2024 14:05:29 +0200 Subject: [PATCH] Add readme for json path and use it as a package --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec193d8 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# JSON-path + +JSON-path is a simple JSON path parser and evaluator for PHP. It is based on the JSONPath +implementation in [Goessner's JSONPath](http://goessner.net/articles/JsonPath/). +The code allows you to parse json paths and evaluate them on php objects. Which makes it a query language for +php object structures. + +It's propably not the fastest solution to query php objects, but as the paths are stored as plain strings, it's +easy to use them in configuration files or databases. This makes is a good solution for tools that need to query +a php object structure based on user input. + +## Installation + +The recommended way to install JSON-path is through [Composer](http://getcomposer.org). + +```bash + composer require phpdocumentor/json-path +``` + +## Usage + +```php + +$parser = \phpDocumentor\JsonPath\Parser::createInstance(); +$query = $parser->parse('.store.book[*].author'); + +$executor = new \phpDocumentor\JsonPath\Executor(); +foreach ($executor->execute($query, $json) as $result) { + var_dump($result); +} + +```