1. Go to this page and download the library: Download seworqs/json-editor 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/ */
seworqs / json-editor example snippets
use Seworqs\Json\JsonEditor;
// Create a new file.
$newJson1 = JsonEditor::createNew("/path/to/save/json/file.json");
// If you want to overwrite a file when it already exists.
$newJson2 = JsonEditor::createNew("/path/to/save/json/file.json", true);
// Create a new file.
$newJson3 = JsonEditor::createFromFile("/path/to/existing/json/file.json");
// Overwrite boolean.
$overwrite = false;
// Add key/value
$newJson3->add('some-key', 'some-value', $overwrite);
// Add key/value in levels deep using dot notation.
$newJson3->add('level1.level2.level3', 'a-deep-value', $overwrite);
// OR Add key/value in levels deep using an array.
$newJson3->add('level1', ['level2' => ['level3' => 'a-deep-level']], $overwrite);
/* Both (using dots or array) will create this:
{
...
"level1": {
"level2": {
"level3": "deep-value"
}
},
...
}
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.