PHPackages                             softcreatr/jsonpath - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. softcreatr/jsonpath

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

softcreatr/jsonpath
===================

JSONPath implementation for parsing, searching and flattening arrays

1.0.2(3mo ago)16534.7M—7.1%3220MITPHPPHP ^8.5CI passing

Since Oct 11Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/SoftCreatR/JSONPath)[ Packagist](https://packagist.org/packages/softcreatr/jsonpath)[ Fund](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4)[ GitHub Sponsors](https://github.com/softcreatr)[ RSS](/packages/softcreatr-jsonpath/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (29)Used By (20)

JSONPath for PHP 8.5+
=====================

[](#jsonpath-for-php-85)

[![Build](https://camo.githubusercontent.com/67e80742cb6ce52529f7602f2bd8c745ceee47876a2ca828b69f4f8908039181/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f536f66744372656174522f4a534f4e506174682f2e6769746875622f776f726b666c6f77732f546573742e796d6c3f6272616e63683d6d61696e)](https://github.com/SoftCreatR/JSONPath/actions/workflows/Test.yml) [![Latest Release](https://camo.githubusercontent.com/ad4b89a3727195106e2c3d95dc621f956c9fe2a019d5da259aa128ed319e6a1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f536f66744372656174522f4a534f4e506174683f636f6c6f723d626c7565266c6162656c3d4c617465737425323052656c65617365)](https://packagist.org/packages/softcreatr/jsonpath)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE) [![Plant Tree](https://camo.githubusercontent.com/e751d267acfa70a4be08989f626ff706c90cec4e0ab98940e620250f26a991be/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f636f6c6f723d627269676874677265656e266c6162656c3d506c616e74253230547265652671756572793d2532342e746f74616c2675726c3d68747470732533412532462532467075626c69632e65636f6c6f67692e636f6d2532467573657273253246736f66746372656174722532467472656573)](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4)[![Codecov branch](https://camo.githubusercontent.com/0ecd8c56d195a247cca0240130c639bbaf1d80c28e3ca2eba4f3efd11e3fa36f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f536f66744372656174522f4a534f4e50617468)](https://codecov.io/gh/SoftCreatR/JSONPath)

This is a [JSONPath](http://goessner.net/articles/JsonPath/) implementation for PHP that targets the de facto comparison suite/RFC semantics while keeping the API small, cached, and `eval`-free.

Highlights
----------

[](#highlights)

- PHP 8.5+ only, with enums/readonly tokens and no `eval`.
- Works with arrays, objects, and `ArrayAccess`/traversables in any combination.
- Unions cover slices/queries/wildcards/multi-key strings (quoted or unquoted); negative indexes and escaped bracket notation are supported.
- Filters support path-to-path/root comparisons, regex, `in`/`nin`/`!in`, deep equality, RFC-style null existence/value handling, and literal-only short-circuiting (e.g., `?(true)`, `?(false)`, `&& false`, `|| true`).
- Tokenized parsing with internal caching; lightweight manual runner to try bundled examples quickly.

Installation
------------

[](#installation)

Requires PHP 8.5 or newer.

```
composer require softcreatr/jsonpath:"^1.0"
```

Development
-----------

[](#development)

Useful commands:

```
composer exec phpunit
composer phpstan
composer cs
```

JSONPath Examples
-----------------

[](#jsonpath-examples)

JSONPathResult`$.store.books[*].author`the authors of all books in the store`$..author`all authors`$.store..price`the price of everything in the store.`$..books[2]`the third book`$..books[(@.length-1)]`the last book in order.`$..books[-1:]`the last book in order.`$..books[0,1]`the first two books`$..books[title,year]`multiple keys in a union`$..books[:2]`the first two books`$..books[::2]`every second book starting from first one`$..books[1:6:3]`every third book starting from 1 till 6`$..books[?(@.isbn)]`filter all books with isbn number`$..books[?(@.price
