Weave Code
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

Jsonpath Laravel Package

peekmo/jsonpath

peekmo/jsonpath adds JSONPath querying to PHP/Laravel, letting you select, filter, and extract values from complex JSON/arrays using familiar JSONPath expressions. Useful for API responses, config inspection, and transforming nested data quickly.

View on GitHub
Deep Wiki
Context7

Library to use JsonPath

Frequently asked questions about Jsonpath
Can I use peekmo/jsonpath in Laravel 9+ for parsing API responses?
Yes, but with caveats. The package works in Laravel, but it lacks PHP 8.x support and may conflict with Laravel’s built-in `json_path()` helper (introduced in Laravel 10). For modern Laravel, consider alternatives like `humbug/jsonpath` for RFC 8907 compliance. Wrap usage in a service class to isolate dependencies.
What PHP versions does peekmo/jsonpath officially support?
The package supports PHP 5.3–5.6 only, as noted in its documentation. It will likely fail on PHP 7.4+ due to deprecated functions like `create_function()`. For newer PHP, use a polyfill or migrate to a modern alternative like `stevegrunwell/jsonpath`.
Does peekmo/jsonpath support JSONPath filters (e.g., `?(@.price > 100)`)?
Yes, it supports basic filters and wildcards (e.g., `$.store..book`), but its implementation is outdated compared to newer libraries. For complex queries like recursive searches (`$..*`) or advanced filters, you may need custom logic or a different package.
How do I install peekmo/jsonpath in a Laravel project?
Add it via Composer: `composer require peekmo/jsonpath`. Register it in a service provider or use it directly: `JsonPath::query($json, '$.path.to.field')`. For Laravel, consider publishing a config file if you need reusable settings, though the package itself is dependency-free.
Is peekmo/jsonpath safe for untrusted JSON input (e.g., API responses)?
No, this package lacks built-in input validation for JSON injection risks (e.g., malformed paths like `$.store..book[?(@.price > $)]`). Always sanitize JSON with `json_decode($json, true)` or use `JSON_THROW_ON_ERROR` in PHP 7.4+ before passing it to the library.
Why should I choose peekmo/jsonpath over humbug/jsonpath or stevegrunwell/jsonpath?
Use this package only if you’re constrained to PHP 5.3–5.6 or need a lightweight drop-in for Stefan Goessner’s original implementation. Alternatives like `humbug/jsonpath` (PHP 8.x, RFC 8907) or `stevegrunwell/jsonpath` (modern features) are actively maintained and support recursive queries, filters, and array slicing.
Will peekmo/jsonpath break if I upgrade PHP from 5.6 to 7.4+?
Yes, it will fail due to deprecated functions. Test thoroughly in a staging environment, or replace it with a PHP 7.4+/8.x-compatible alternative. Wrap usage in a service class to isolate the dependency and log deprecation warnings for future migration.
Can I use peekmo/jsonpath for dynamic field access in Laravel Eloquent models?
Technically yes, but it’s not recommended for production. The package lacks Laravel-specific optimizations (e.g., query caching, model event hooks). For dynamic access, consider Laravel’s `json_path()` (v10+) or a hybrid approach with `json_decode()` + manual traversal for complex cases.
Are there any performance issues with deep JSONPath queries in peekmo/jsonpath?
Yes, deep or complex queries may underperform compared to modern implementations. The package lacks optimizations like recursive descent or array slicing. Benchmark against alternatives like `stevegrunwell/jsonpath` if you’re processing large datasets or nested structures.
How do I handle edge cases like circular references or non-string JSON keys?
The package doesn’t explicitly handle circular references and may throw errors on non-string keys. Validate JSON with `json_decode($json, true)` first, and use try-catch blocks for robustness. For circular data, consider flattening the structure or using a custom parser.
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope