pnz/json-exception
最新稳定版本:v1.0.1
Composer 安装命令:
composer require pnz/json-exception
包简介
Json decode/encode library with exception throwing on error.
关键字:
README 文档
README
Usage
This library provides Json::decode() and Json::encode() implementations throwing \JsonException on errors.
To use this library:
- install the library by using composer:
composer require pnz/json-exception - replace the usage of
json_decode()withJson::decode() - replace the usage of
json_encode()withJson::encode() - catch the
\JsonExceptioneventually thrown by the functions
Example: Old code
$data = json_decode($jsonString, ...); if (ERROR_NONE !== json_last_error()) { // handle the error: thown a custom exception, or return // $error = json_last_error_msg(); // $errorCode = json_last_error(); }
new code:
try { $data = Json::decode($jsonString, ...); } catch(\JsonException $e) { // Handle the exception }
Development
To run the PHP coding-styles checks (php-cs-fixer and phpstan) run the make phpcs command to:
- download the
php-cs-fixertool intools/(if not present) - download the
phpstantool intools/(if not present) - Run
php-cs-fixeron the source code - Run
phpstanon the source code
To run the tests, use make tests to
- download
phpunittool intools/if not present - run
phpunittests
统计信息
- 总下载量: 354.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2018-11-07