1. Go to this page and download the library: Download remorhaz/php-json-path library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
remorhaz / php-json-path example snippets
use Remorhaz\JSON\Data\Value\EncodedJson;
use Remorhaz\JSON\Data\Value\DecodedJson;
// Creating document from JSON-encoded string:
$encodedValueFactory = EncodedJson\NodeValueFactory::create();
$encodedJson = '{"a":1}';
$document1 = $encodedValueFactory->createValue($encodedJson);
// Creating document from decoded JSON data:
$decodedValueFactory = DecodedJson\NodeValueFactory::create();
$decodedJson = (object) ['a' => 1];
$document2 = $decodedValueFactory->createValue($decodedJson);
use Remorhaz\JSON\Path\Query\QueryFactory;
$queryFactory = QueryFactory::create();
// Creating query that selects all 'a' properties from any document:
$query = $queryFactory->createQuery('$..a');
use Remorhaz\JSON\Path\Processor\Processor;
$processor = Processor::create();