PHPackages                             pavelmaksimov25/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. pavelmaksimov25/jsonpath

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

pavelmaksimov25/jsonpath
========================

Fork of the JSONPath implementation for parsing, searching and flattening arrays

0.2.1(2y ago)02.2k1MITPHPPHP &gt;7.4 || &gt;=8.0

Since May 25Pushed 2y agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (2)Used By (1)

JSONPath for PHP 7.4+
=====================

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

[![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/025a5438f7bf37d5a39ec4032690c7527eea422c0e3940c9d4101ef5578fd6f7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f636f6c6f723d627269676874677265656e266c6162656c3d506c616e74253230547265652671756572793d2532342e746f74616c2675726c3d68747470732533412532462532467075626c69632e6f66667365742e65617274682532467573657273253246736f66746372656174722532467472656573)](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4)[![Codecov branch](https://camo.githubusercontent.com/0ecd8c56d195a247cca0240130c639bbaf1d80c28e3ca2eba4f3efd11e3fa36f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f536f66744372656174522f4a534f4e50617468)](https://codecov.io/gh/SoftCreatR/JSONPath)[![Code Climate maintainability](https://camo.githubusercontent.com/969e306c47702a3056570363df2b2990660482f755ab864069eb5c47989ae13c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792d70657263656e746167652f536f66744372656174522f4a534f4e50617468)](https://codeclimate.com/github/SoftCreatR/JSONPath)

This is a [JSONPath](http://goessner.net/articles/JsonPath/) implementation for PHP based on Stefan Goessner's JSONPath script.

JSONPath is an XPath-like expression language for filtering, flattening and extracting data.

This project aims to be a clean and simple implementation with the following goals:

- Object-oriented code (should be easier to manage or extend in future)
- Expressions are parsed into tokens using code inspired by the Doctrine Lexer. The tokens are cached internally to avoid re-parsing the expressions.
- There is no `eval()` in use
- Any combination of objects/arrays/ArrayAccess-objects can be used as the data input which is great if you're de-serializing JSON in to objects or if you want to process your own data structures.

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

[](#installation)

```
composer require softcreatr/jsonpath:"^0.5 || ^0.7 || ^0.8"
```

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[: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
