mtdowling/jmespath.php 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.| Name | Version | Size | License | Type | Vulnerabilities |
|---|---|---|---|---|---|
| symfony/polyfill-mbstring | v1.30.0 | - | MIT | prod |
The mtdowling/jmespath.php is a powerful tool that allows PHP developers to declaratively specify how to extract elements from a JSON document. In simpler terms, it's a way to query JSON documents within your PHP applications, making it ideal for handling, searching, and filtering complex data structures. The package is compliant with PHP versions 7.2.5 and above, and it can be easily installed via Composer.
To use the mtdowling/jmespath.php package, first, you need to install it using Composer, a tool for dependency management in PHP. If you're new to Composer, you'll find its documentation at https://getcomposer.org/doc/00-intro.md. Once installed, you can use the package by requiring the autoload.php file, which is generated by Composer, in your PHP script. After that, use the JmesPath\search function to analyze your JSON data. Here is a simple instance:
require 'vendor/autoload.php';
$expression = 'foo.*.baz';
$data = [
'foo' => [
'bar' => ['baz' => 1],
'bam' => ['baz' => 2],
'boo' => ['baz' => 3]
]
];
$result = JmesPath\search($expression, $data);
// The $result will have [1, 2, 3]
In this given illustration, $expression is the JMESPath expression defining the data you want to extract from the $data array. Note that you can also use JmesPath\Env::search if you require PSR-4 compliance.
For comprehensive understanding about mtdowling/jmespath.php usage, please have a look at the official documentation of JMESPath available at https://jmespath.org/tutorial.html. Also, the complete JMESPath specs are available at https://jmespath.org/specification.html#grammar, it gives a detailed overview of the grammar of JMESPath. More PHP specific examples and comprehensive test cases can be found at https://github.com/jmespath/jmespath.php/tree/master/tests/compliance.