https://github.com/symfony/json-path
Eases JSON navigation using the JSONPath syntax as described in RFC 9535
https://github.com/symfony/json-path
component php symfony symfony-component
Last synced: about 2 months ago
JSON representation
Eases JSON navigation using the JSONPath syntax as described in RFC 9535
- Host: GitHub
- URL: https://github.com/symfony/json-path
- Owner: symfony
- License: mit
- Created: 2025-05-02T13:04:33.000Z (11 months ago)
- Default Branch: 7.3
- Last Pushed: 2025-12-31T09:30:29.000Z (3 months ago)
- Last Synced: 2026-01-04T12:34:06.878Z (3 months ago)
- Topics: component, php, symfony, symfony-component
- Language: PHP
- Homepage: https://symfony.com/json-path
- Size: 246 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
JsonPath Component
==================
The JsonPath component eases JSON navigation using the JSONPath syntax as described in [RFC 9535](https://www.rfc-editor.org/rfc/rfc9535.html).
**This Component is experimental**.
[Experimental features](https://symfony.com/doc/current/contributing/code/experimental.html)
are not covered by Symfony's
[Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html).
Getting Started
---------------
```bash
composer require symfony/json-path
```
```php
use Symfony\Component\JsonPath\JsonCrawler;
$json = <<<'JSON'
{"store": {"book": [
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
]}}
JSON;
$crawler = new JsonCrawler($json);
$result = $crawler->find('$.store.book[0].title');
$result = $crawler->find('$.store.book[?match(@.author, "[A-Z].*el.+")]');
$result = $crawler->find("$.store.book[?(@.category == 'fiction')].title");
```
Updating the Compliance Test Suite
----------------------------------
The compliance test suite is gathered from the [JSONPath Test Suite](https://github.com/jsonpath-standard/jsonpath-compliance-test-suite).
When new commits are pushed to the upstream repository, it is necessary to gather them by following these steps:
* Update the `reference` field of `composer.json` to the latest commit hash of the `jsonpath-standard/jsonpath-compliance-test-suite` package
* Update the `version` field to the date of the commit
* Repeat the steps above for the `composer.json` file present at the root level of the `symfony/symfony` repository
* Run `composer update`
* Ensure the tests pass
Resources
---------
* [Documentation](https://symfony.com/doc/current/components/json_path.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)