Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Path Laravel Package

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.

View on GitHub
Deep Wiki
Context7

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

Frequently asked questions about Json Path
How do I install symfony/json-path in a Laravel application?
Install it with composer require symfony/json-path, which pulls in only the Symfony JsonPath component and its small set of dependencies. There is no Laravel auto-discovery service provider, so after installation you can use the Symfony\Component\JsonPath\JsonCrawler class directly or bind it in the container yourself. Verify the resolved Composer constraints against your existing symfony/http-client, symfony/serializer, and any other JSON packages before rolling out.
How do I evaluate a JSONPath query with JsonCrawler?
Create a JsonCrawler instance by passing the raw JSON string to its constructor, then call find() with your JSONPath expression. For example, new JsonCrawler($json)->find('$.store.book[0].title') returns the title of the first book. The same method accepts filter expressions such as $.store.book[?(@.category == 'fiction')].title, so you can extract a whole projection in one call instead of looping through decoded arrays.
Does symfony/json-path support RFC 9535 features like filters, slices, and match() or search() functions?
Yes. The component implements the JSONPath syntax described in RFC 9535, including wildcards, recursive descent, array index and slice selectors, and filter expressions. It also supports the standard match() and search() functions for regular expression tests inside filters, as shown in the README example that filters authors against a pattern. Compliance is tracked against the upstream JSONPath compliance test suite, so behaviour should match other RFC 9535 implementations more closely than ad hoc parsers.
Which Laravel and PHP versions are compatible with symfony/json-path?
The package follows Symfony's release cycle, so its PHP requirement tracks the Symfony branch you install; the 8.x line targets modern PHP versions while older branches support older runtimes. Laravel is built on Symfony components, so there is no expected conflict, but you should confirm the resolved dependency set with composer why-not or a dry-run install. Always validate against your project's exact Laravel and PHP matrix, especially if you are still on a Laravel version that pins older Symfony packages.
Do I need a service provider or facade to use symfony/json-path in Laravel?
No, the component works standalone, but registering it in the container is recommended for consistency and testability. You can add $this->app->singleton(JsonPath::class) or a small factory that builds JsonCrawler instances in AppServiceProvider. Wrapping it behind a facade or a dedicated service class keeps controllers and jobs from constructing crawlers inline and makes swapping implementations later much easier.
How is symfony/json-path different from Laravel's data_get helper or manual json_decode traversal?
data_get works well for simple dot-notation lookups on arrays and objects, but it cannot express wildcards, recursive descent, slices, or filter predicates. Manual json_decode plus nested loops gets unreadable quickly and often hides null-handling bugs. JSONPath lets you declare the shape of the data you want in a single expression, which is far cleaner for third-party API responses, ETL pipelines, and configurable integrations.
Is symfony/json-path fast enough for large or deeply nested JSON payloads?
The dependency footprint is small, so the main cost is parsing and evaluating the path rather than loading a heavy framework. For high-volume workloads, benchmark against native json_decode plus manual traversal, and profile queries over documents above roughly 1 MB or with deep recursion. If the same document is queried repeatedly, decode and cache it once instead of re-parsing on every request or job run.
How should I test JSONPath queries in Pest or PHPUnit?
Store representative JSON payloads as fixtures and assert on the arrays returned by find() for each expression you depend on. Cover wildcards, recursive descent, filters, escaped keys, and arrays containing null elements in CI. If you rely on key escaping or match() and search() anchoring, add explicit regression tests for those cases so future upgrades cannot silently change results.
Why should I upgrade to symfony/json-path 8.1.9 and what does it fix?
Version 8.1.9 is a patch-level correctness release that fixes JSONPath escaping, anchoring and slash escaping in match() and search(), and index and slice behaviour over arrays containing null elements. Earlier versions could silently drop null array entries, so if your data includes nulls inside arrays you should pin >=8.1.9 before piloting. There are no new features or deprecations, so the upgrade is low risk but worth regression testing.
Is symfony/json-path actively maintained, and what are the alternatives?
It is a first-party Symfony component, developed in the main symfony/symfony repository, MIT licensed, and backed by Symfony's regular release and security process. That makes long-term availability predictable for Laravel projects, though you should still watch Symfony release notes for behavioural changes. Alternatives include softcreatr/jsonpath and galbar/jsonpath, but they may not follow RFC 9535 as closely, so compare compliance behaviour before switching.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings