symfony/json-path

Eases JSON navigation using the JSONPath syntax as described in RFC 9535

Installs: 42 271

Dependents: 0

Suggesters: 0

Security: 0

Stars: 17

Watchers: 2

Forks: 0

pkg:composer/symfony/json-path

v8.0.1 2025-12-01 09:13 UTC

README

The JsonPath component eases JSON navigation using the JSONPath syntax as described in RFC 9535.

This Component is experimental. Experimental features are not covered by Symfony's Backward Compatibility Promise.

Getting Started

composer require symfony/json-path
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.

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