codedgr / json
JSON helper library
1.0.1
2018-05-26 14:53 UTC
Requires
- php: >=7.1.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2025-04-14 20:05:42 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