1. Go to this page and download the library: Download jess/jsonkit-php 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/ */
jess / jsonkit-php example snippets
use Jess\JsonkitPhp\JsonFileManager;
// Initialize from a file path
$handler = new JsonFileManager('data.json', true);
// Get all data
$data = $handler->all();
// Get a value (dot notation supported)
$name = $handler->get('user.name');
// Set a value
$handler->set('user.age', 30);
// Append a value to an array
$handler->appendArray('tags', 'php');
// Remove a value from an array
$handler->removeArrayValue('tags', 'php');
// Remove where condition
$handler->removeWhere('users', function($user) {
return $user['active'] === false;
});
// Save changes
$handler->save();
// You can load array data and save it to a json file.
$arr = [
'numbers' => ['1', '2', '3']
];
$data = $handler->load($arr)->save(__DIR__ . 'test.json');
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.