PHP code example of skyscanner / jsonpath
1. Go to this page and download the library: Download skyscanner/jsonpath 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/ */
skyscanner / jsonpath example snippets
use JsonPath\JsonObject;
// $json can be a string containing json, a PHP array, a PHP object or null.
// If $json is null (or not present) the JsonObject will be empty.
$jsonObject = new JsonObject();
// or
$jsonObject = new JsonObject($json);
// get
$obj->get($jsonPath);
$obj->{'$.json.path'};
// set
$obj->set($jsonPath, $value);
$obj->{'$.json.path'} = $value;
// get the json representation
$obj->getJson();
$str = (string)$obj;
echo $obj;
// get the PHP array representation
$obj->getValue();
// add values
$obj->add($jsonPath, $value[, $field]);
// remove values
$obj->remove($jsonPath, $field);