1. Go to this page and download the library: Download arturdoruch/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/ */
arturdoruch / json example snippets
use ArturDoruch\Json\Json;
use ArturDoruch\Json\UnexpectedJsonException;
$jsonString = '';
// Decode JSON to array or stdClass object.
// If JSON is invalid `ArturDoruch\Json\UnexpectedJsonException` is thrown.
$json = new Json($jsonString);
// Get decoded JSON.
$json->getDecoded();
// Get encoded JSON with specified options like JSON_PRETTY_PRINT.
$json->getEncoded();
// Catch decoding exception
try {
$json = new Json($jsonString);
} catch (UnexpectedJsonException $exception) {
// Get decoded invalid JSON.
$exception->getJson();
// Get error code.
$exception->getCode();
}