定制 im-denisenko/php-json-encode 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

im-denisenko/php-json-encode

最新稳定版本:0.0.3

Composer 安装命令:

composer require im-denisenko/php-json-encode

包简介

Provides features, added to json_encode since version 5.3.0, for version 5.3.0.

README 文档

README

Build Status

Provides features, added to json_encode since version 5.3.0, for version 5.3.0.

Reference

  • >=5.5.0 Third parameter $depth allow let you set the maximum depth.

  • >=5.4.0 Option JSON_PRETTY_PRINT let use whitespace in returned data to format it.

  • >=5.4.0 Option JSON_UNESCAPED_SLASHES let don't escape /.

  • >=5.4.0 Option JSON_UNESCAPED_UNICODE let encode multibyte Unicode characters literally (default is to escape as \uXXXX).

  • >=5.3.3 Option JSON_NUMERIC_CHECK let you encode numeric strings as numbers.

Usage

$data = array('foo' => 'bar');
echo Future\Json::encode($data, JSON_PRETTY_PRINT);
echo Future\Json::encode($data, JSON_NUMERIC_CHECK);
echo Future\Json::encode($data, JSON_UNESCAPED_SLASHES);
echo Future\Json::encode($data, JSON_UNESCAPED_UNICODE);
echo Future\Json::encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
echo Future\Json::encode($data, null, 4);

Shortcut

If you dont like Namespace\Classname::staticMethod call, you can use shortcuts.

future_json_encode($data, JSON_UNESCAPED_UNICODE, 10);

Testing

If current version PHP allow to use features described above, then encoder will pass all arguments to native function instead.

Directory tests/ contains json files that were generated using native function in PHP 5.5.6.

You can run the unit tests just to be sure that you will get exactly the same result regardless of your system:

$ composer install --dev
$ vendor/bin/phpunit tests/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-25