codedgr / json
JSON helper library
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
pkg:composer/codedgr/json
Requires
- php: >=7.1.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2025-10-14 21:24:20 UTC
README
This library throws an exception every time a json encode/decode action fails.
Install
Using Composer
"require": {
"codedgr/json": "~1.0"
}
Usage
Define an array
$array = [
'first-element' => 'this value',
'second-element' => [0,1,2,3,4],
];
Then use the encode
and decode
functions surrounded with try/catch
try{
$encodedJSON = JSON::encode($array);
$object = JSON::decode($encodedJSON);
}catch (JSONException $e){
echo $e->getMessage();
}
Requirements
- PHP 7.1 or above