qligier/tjson-parser

此软件包已被废弃,不再维护。没有建议的替代软件包。

PHP 解析 TJSON 格式的工具

0.1.1 2017-10-25 19:44 UTC

This package is not auto-updated.

Last update: 2022-07-09 17:04:26 UTC


README

用 PHP 编写的 TJSON 解析器,使用 Phlexy 作为 JSON 标识符。

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f716c69676965722f746a736f6e2d7061727365722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f716c69676965722f746a736f6e2d7061727365722e7376673f7374796c653d666c61742d737175617265 StyleCI Shield 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c25323076332d626c75652e7376673f7374796c653d666c61742d737175617265

需求

  • 至少需要 PHP 7.0;
  • 需要 GMP 扩展。

快速开始

安装

使用 composer 安装库

composer require qligier/tjson-parser

用法

$parser = new Kentin\TJSON\Parser;
$tjson = '{"message:u":"Hello World!"}';

var_dump($parser->parse($tjson));
/*
array(1) {
  'message' =>
  string(12) "Hello World!"
}
*/

数据映射

  • 布尔 值作为布尔值返回;
  • 二进制 值被解码并作为字符串返回;
  • 浮点 值作为浮点数返回;
  • 整数 值作为 GMP 实例返回;
  • UnicodeString 值作为字符串返回;
  • 时间戳 值作为 DateTime 实例返回;
  • 数组 值作为索引数组返回;
  • 对象 值作为关联数组返回;
  • 集合 值作为索引数组返回。

兼容性

此库试图完全符合当前的 draft-tjson-spec(2017年4月15日)。尽管如此,以下不符合规范的情况并不排除

  • 该库接受各种格式化的 FloatingPointInteger 值,这些值可能被规范 禁止

开发

使用 Psalm(用于查找错误的静态分析工具)检查库;

./vendor/bin/psalm

使用 PHPUnit(单元测试框架)执行单元测试;

./vendor/bin/phpunit

使用 Infection(突变测试框架)检查库;

./vendor/bin/infection --min-msi=100 --min-covered-msi=100

使用 PHP Coding Standards Fixer(用于自动修复 PHP 编码标准问题的工具)检查和修复代码风格。

./vendor/bin/php-cs-fixer fix . --dry-run --diff
./vendor/bin/php-cs-fixer fix .