PHP code example of kherge / json
1. Go to this page and download the library: Download kherge/json 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/ */
kherge / json example snippets
use KHerGe\JSON\JSON;
$json = new JSON();
// Decode JSON values.
$decoded = $json->decode('{"test":123}');
// Decode JSON values in files.
$decoded = $json->decodeFile('/path/to/file.json');
// Encode native values.
$encoded = $json->encode(['test' => 123]);
// Encode native values into files.
$json->encodeFile(['test' => 123], '/path/to/file.json');
// Lint an encoded JSON value.
$json->lint('{"test":}');
// Lint an encoded JSON value in a file.
$json->lintFile('/path/to/file.json');
// Validate a decoded JSON value using a JSON schema.
$json->validate(
$json->decodeFile('/path/to/schema.json'),
$decoded
);