承接 ttree/serializer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ttree/serializer

最新稳定版本:1.0.1

Composer 安装命令:

composer require ttree/serializer

包简介

Package for TYPO3 Flow to convert PHP object to and from JSON

README 文档

README

Build Status Total Downloads

This package can be used to convert PHP object to and from JSON. The current version support object tree, but no circular references, as there is no way to represent this kind of reference in a JSON file.

Usage

Use DI to inject the Ttree\Serializer\SerializerInterface where you need it:

class ObjectUtility {

	/**
	 * @Flow\Inject
	 * @var \Ttree\Serializer\SerializerInterface
	 */
	protected $serializer;

	/**
	 * @param object $object
	 * @return string
	 */
	public function save($object) {
		$json = $this->serializer->serialize($object);
	}
	
	/**
	 * @param string $string
	 * @return object
	 */
	public function load($string) {
		$json = $this->serializer->unserialize($string);
	}

}

Skip property

The serializer will only include gettable properties. Transient property in a Doctrine entity are skipped automaticaly.

You can skip any property by using the Ttree\Serializer\Annotations\Skip.

Functional Programming

You can also use directly the objects Ttree\Serializer\Json\Serialize and Ttree\Serializer\Json\Serialize in a functionnal style programming:

$serialize = new Serialize();
$json = $serialize(array('Hello', 'World'));
$unserialize = new Unserialize();
$array = $unserialize('["Hello","World"]')

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2014-11-07