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

ActivePhp-ext[Parsing &amp; Serialization](/categories/parsing)

supermetrics/jsonpath
=====================

Extract data from a decoded JSON document using the versatile JSONPath query language

v3.1.0(5mo ago)293.4k4[2 PRs](https://github.com/supermetrics-public/pecl-jsonpath/pulls)PHP-3.01PHPPHP &gt;=8.0,&lt;8.6CI passing

Since Jan 27Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/supermetrics-public/pecl-jsonpath)[ Packagist](https://packagist.org/packages/supermetrics/jsonpath)[ RSS](/packages/supermetrics-jsonpath/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (5)Used By (0)

JsonPath-PHP - extension for PHP 8.1+
=====================================

[](#jsonpath-php---extension-for-php-81)

[![Linux build status](https://github.com/supermetrics-public/pecl-jsonpath/workflows/Build%20and%20test%20on%20Linux/badge.svg)](https://github.com/supermetrics-public/pecl-jsonpath/actions/workflows/build-linux.yml)[![Windows build status](https://github.com/supermetrics-public/pecl-jsonpath/workflows/Build%20and%20test%20on%20Windows/badge.svg)](https://github.com/supermetrics-public/pecl-jsonpath/actions/workflows/build-windows.yml)[![Code coverage](https://camo.githubusercontent.com/3cbe3063e394cf9513d1f33ef4661d9f3a2e2a882aebb8fb8c1fe3b729342db2/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f63726f636f64656c652f35636562303838343566653935363335666334316166326634633836633633312f7261772f7065636c2d6a736f6e706174685f5f6d61696e2e6a736f6e266c6162656c436f6c6f723d333433393430)](https://camo.githubusercontent.com/3cbe3063e394cf9513d1f33ef4661d9f3a2e2a882aebb8fb8c1fe3b729342db2/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f63726f636f64656c652f35636562303838343566653935363335666334316166326634633836633633312f7261772f7065636c2d6a736f6e706174685f5f6d61696e2e6a736f6e266c6162656c436f6c6f723d333433393430)

JSONPath is a language for querying and extracting data from JSON, similar to XPath for XML.

This PHP extension for JSONPath is inspired by [Stefan Goessner's original implementation](https://goessner.net/articles/JsonPath/)and is intended to be a fast(er) replacement for JSONPath libraries written in PHP.

Intended audience
-----------------

[](#intended-audience)

This extension is ideal for projects that depend heavily on JSONPath and could benefit from a native C implementation. Other JSONPath implementations often rely on `eval()` and regular expressions, while JsonPath-PHP is a more efficient lexer/parser. Extracting the data in C rather than in PHP results in great performance. In fact, JsonPath-PHP is often faster than manually traversing the array in PHP and picking the matching element(s).

The tradeoff for increased performance is the overhead of adding this extension to your PHP installation. If you're running your PHP application in a shared environment where you can't install PHP extensions, we recommend checking out more convenient PHP implementations like [this](https://github.com/SoftCreatR/JSONPath), [this](https://github.com/Galbar/JsonPath-PHP), and [this](https://github.com/Peekmo/JsonPath). Or switching to an environment that you have more control over. 😉

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

[](#installation)

### Linux and macOS

[](#linux-and-macos)

#### Option 1: Build using PECL

[](#option-1-build-using-pecl)

```
$ pecl install jsonpath
```

For more instructions on how to use PECL, [see the PECL documentation](https://www.php.net/manual/en/install.pecl.php).

#### Option 2: Build manually

[](#option-2-build-manually)

Clone this repository to the directory of your choice, then run:

```
$ phpize
$ ./configure --enable-jsonpath
$ make
$ TEST_PHP_ARGS="-q" make test
$ sudo make install
```

#### Enable the extension

[](#enable-the-extension)

```
$ sudo touch /etc/php.d/jsonpath.ini
$ echo "extension=jsonpath.so" | sudo tee /etc/php.d/jsonpath.ini
$ php -m | grep jsonpath
```

If you're running PHP with the PHP-FPM service, restart it for the changes to take effect:

```
$ sudo service php-fpm restart
```

### Windows

[](#windows)

For pre-built Windows DLLs, see the [PHP Extensions Repository](https://phpext.phptools.online/extension/tools-and-utilities/jsonpath-308).

Remember to add `extension=jsonpath` to your php.ini in order to enable the extension.

For more instructions on installing PHP extensions, [see the PECL documentation](https://www.php.net/manual/en/install.pecl.windows.php).

Usage
-----

[](#usage)

```
