egeloen / serializer
支持 PHP 5.6+ 的序列化器,支持 JSON、XML、YAML 和 CSV 格式
1.0.0
2017-02-27 21:35 UTC
Requires
- php: ^5.6|^7.0
- doctrine/instantiator: ^1.0
- doctrine/lexer: ^1.0
- symfony/options-resolver: ^2.7|^3.0
Requires (Dev)
- ext-dom: *
- ext-json: *
- ext-simplexml: *
- doctrine/annotations: ^1.2
- friendsofphp/php-cs-fixer: ^2.0
- nikic/php-parser: ^1.4
- phpdocumentor/reflection: ^3.0
- phpunit/phpunit: ^5.4
- phpunit/phpunit-mock-objects: ^3.2.3
- psr/cache: ^1.0
- symfony/event-dispatcher: ^2.7|^3.0
- symfony/phpunit-bridge: ^2.7|^3.0
- symfony/property-access: ^2.7|^3.0
- symfony/property-info: ^2.7|^3.0
- symfony/yaml: ^2.7|^3.0
Suggests
- ext-dom: Allow you to use the XML serialization visitor and mapping.
- ext-json: Allow you to use the JSON serialization/deserialization visitors and mapping.
- ext-simplexml: Allow you to use the XML deserialization visitor and mapping.
- doctrine/annotations: Allow you to use the mapping annotations.
- phpdocumentor/reflection: Allow you to parse PHP type more efficiently
- symfony/event-dispatcher: Allow you to use the event dispatching system.
- symfony/property-access: Allow you to use the Symfony accessor/mutator.
- symfony/property-info: Allow you to use the mapping type auto discovery.
- symfony/yaml: Allow you to use the YAML serialization/deserialization visitors and mapping.
This package is not auto-updated.
Last update: 2024-09-13 22:33:28 UTC
README
概述
Ivory 序列化器是一个 PHP 5.6+ 库,允许您通过访问者模式递归地在图的每个节点上(反)序列化复杂数据。它支持 CSV、JSON、XML 和 YAML 格式。它还支持排除策略(组、最大深度、循环引用、版本等)、命名策略(驼峰式、蛇形、PascalCase)以及自动/显式映射(反射、注解、XML、YAML、JSON)等功能...
use Ivory\Serializer\Format; use Ivory\Serializer\Serializer; $stdClass = new \stdClass(); $stdClass->foo = true; $stdClass->bar = ['foo', [123, 432.1]]; $serializer = new Serializer(); echo $serializer->serialize($stdClass, Format::JSON); // {"foo": true,"bar": ["foo", [123, 432.1]]} $deserialize = $serializer->deserialize($json, \stdClass::class, Format::JSON); // $deserialize == $stdClass
文档
测试
该库由 PHPUnit 进行全面单元测试,代码覆盖率接近 100%。要执行测试套件,请检查 Travis 配置。
贡献
我们热爱贡献者!Ivory 是一个开源项目。如果您想做出贡献,请随时提出 PR!您可以查看 CONTRIBUTING 文件,该文件将向您解释如何设置项目。
许可协议
Ivory 序列化器采用 MIT 许可协议。有关完整的版权和许可信息,请阅读随源代码一起分发的 LICENSE 文件。