Files
archived-json-path/README.md
Nicolas Grekas 84db78b1f0 Merge branch '7.3' into 7.4
* 7.3:
  [JsonPath] Use composer packages for JsonPath compliance test suite
  Fix negative delays with AMQP messenger transport
  [TwigBundle] Align TemplateIterator handling of @! original bundle templates with TwigExtension
  [AssetMapper] Batch concurrent requests to prevent flooding jsdelivr
  [HttpFoundation][Cache] Fix VARBINARY columns on sqlsrv
  [Cache] Fix calling the callback wrapper for ChainAdapter
  [Routing] Fix simple parameter mappings in routes
  [Process] Fix dealing with broken stdin pipes
2025-12-19 11:00:43 +01:00

1.8 KiB

JsonPath Component

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

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