symfony/json-path
Symfony JsonPath is a PHP component for navigating and querying JSON using JSONPath syntax per RFC 9535. Use JsonCrawler to evaluate paths, filter expressions, and extract values from complex JSON documents.
json_decode() traversal in controllers and services. Works alongside Laravel Collection macros and database JSON columns.match()/search(), and index/slice behavior for null array elements. No new features or deprecations are indicated.match() / search().null elements.json_decode() plus traversal for high-volume or deeply nested payloads.| Risk | Mitigation |
|---|---|
| RFC 9535 / JSONPath Edge Cases | Add CI fixtures for wildcards, recursive descent, filters, escaped keys, and null array elements. |
| v8.1.9 Correctness Fixes | Upgrade to >=8.1.9 before piloting if current code relies on key escaping, match()/search() anchoring, or arrays containing null. |
| Performance Bottlenecks | Profile deep/nested queries and large payloads; cache parsed JSON when repeated queries are needed. |
| Dependency Bloat / Conflicts | No Laravel Symfony conflict expected, but verify Composer constraints against symfony/http-client, symfony/serializer, and existing JSON packages. |
| Deprecation Risk | Monitor Symfony JSONPath releases; MIT license allows fork or replacement if upstream changes become disruptive. |
| Silent Data Loss | Prior index/slice behavior could drop null array elements; ensure v8.1.9 is installed and regression-tested. |
null array elements or querying keys with backslashes/control characters? If yes, v8.1.9 testing is mandatory.// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->singleton(\Symfony\Component\JsonPath\JsonPath::class);
}
// app/Facades/JsonPath.php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class JsonPath extends Facade { protected static function getFacadeAccessor() { return 'jsonPath'; } }
Collection::macro('jsonPath', function ($path) {
return JsonPath::search($this->toJson(), $path);
});
symfony/json-path >=8.1.9.// Before
$data = json_decode($response->getBody(), true);
$value = $data['user']['profile']['name'];
// After
$value = JsonPath::search($response->getBody(), '$.user.profile.name');
match()/search() anchoring, and arrays containing null.| Step | Priority | Effort | Dependencies |
|---|---|---|---|
Upgrade to symfony/json-path >=8.1.9 |
High | Low | Composer lockfile review |
| Regression tests for v8.1.9 fixes | High | Medium | Fixtures for escaping, anchoring, null arrays |
| Facade/Service setup | Medium | Low | JSONPath class |
| Pilot in API layer | High | Medium | Existing API handlers |
| Collection macro | Low | Low | AppServiceProvider |
| CI coverage and documentation | High | Medium | Pest/PHPUnit, internal docs |
null.match() vs search() anchoring behavior.try {
$result = JsonPath::search($json, $path);
} catch (\Symfony\Component\JsonPath\Exception\JsonPathException $e) {
Log::error("Invalid JSONPath [$path]: " . $e->getMessage(), ['json' => $json]);
}
null elements; upgrade and test to prevent silent data loss.match() and search() behavior around anchoring and slash escaping is corrected in v8.1.9; regression-test if used.How can I help you explore Laravel packages today?