inerciacreativa/json
最新稳定版本:v1.0.0
Composer 安装命令:
composer require inerciacreativa/json
包简介
PHP class for working with JSON objects
README 文档
README
The package provides methods to encode and decode JSON.
- It has sensible defaults, so you don't have to specify flags all the time.
- It has handy method to encode for HTML safely.
- It throws
\IC\Json\Exception\JsonEncodeExceptionwhen encoding fails. - It throws
\IC\Json\Exception\JsonDecodeExceptionwhen decoding fails. - It handles
\JsonSerializable,\DateTimeInterface, and\SimpleXMLElementwell.
Requirements
- PHP 8.0 or higher.
SimpleXMLPHP extension.
Installation
The package could be installed with composer:
composer require inerciacreativa/json --prefer-dist
General usage
Encoding:
use \IC\Json\Json; $data = ['name' => 'Jose', 'team' => 'Inercia Creativa']; $json = Json::encode($data);
Encoding for HTML:
use \IC\Json\Json; $data = ['name' => 'Jose', 'team' => 'Inercia Creativa']; $json = Json::htmlEncode($data);
Decoding:
use \IC\Json\Json; $json = '{"name":"Jose","team":"Inercia Creativa"}'; $data = Json::decode($json);
Testing
Unit testing
The package is tested with PHPUnit. To run tests:
composer phpunit
Static analysis
The code is statically analyzed with PHPStan. To run static analysis:
composer phpstan
License
The IC JSON is free software. It is released under the terms of the MIT License.
Please see LICENSE for more information.
Maintained by Inercia Creativa.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-04