This package can be used with PHP 7.3 or higher. You can install the package via composer:
composer require finagin/json
use Finagin\Json\Facades\Json;
try {
// decode as object
Json::decode($fromJson);
Json::decodeAsObject($fromJson);
// decode as array
Json::decode($fromJson, 0, true);
Json::decodeAsArray($fromJson);
Json::encode($toJson, JSON_PRETTY_PRINT);
} catch (\JsonException $exception) {
//
}
The MIT License (MIT). Please see License File for more information.