jedkirby/json 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jedkirby/json

最新稳定版本:0.1.0

Composer 安装命令:

composer create-project jedkirby/json

包简介

关键字:

README 文档

README

This package is designed to bridge the gap between the default json_* methods, ensuring a fluent and easy to use structure.

Installation

This package can be installed via [Composer]:

$ composer require jedkirby/json

It requires PHP >= 7.0.0.

Usage

The following guide assumes that you've imported the class Jedkirby\Json into your namespace.

The Json constructor requires you to pass the exact same methods as the json_decode method, however, is provides additional functionality once initilised.

The following code should help explain using this package, thus providing the fluent and easy to use structure:

$json = new Json('{"name":"James Kirby"}');

if (false === $json->isValid()) {
    throw new RuntimeException(sprintf(
        'Parsing failed with error "%s"',
        $json->getErrorMessage()
    ));
}

return $json->getResponse();

Helpers

There's a couple of helper methods built in, which provide additional functionality, these are listed below:

Method Description
Json::decode() Alias for the new Json() method, passing the same arguments.
Json::decodeFromPath() Helper to read contents from a provided $path, which is the first argument instead of a JSON string.

Testing

Unit tests can be run within the package, however, it utilises Docker & Docker Compose:

$ docker-compose -f ./docker-compose.yml run --rm cli php ./vendor/bin/phpunit

License

jedkirby/json is licensed under the MIT license. See the LICENSE file for more details.

统计信息

  • 总下载量: 231.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-17