kunststube / rison
该包的最新版本(0.92.1)没有可用的许可证信息。
Rison的PHP编码器和解码器,Rison是一种针对URI优化的紧凑型JSON-like数据格式。
0.92.1
2015-02-10 01:18 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-14 14:11:54 UTC
README
Rison是一种针对URI优化的紧凑型数据格式,是JSON的一种轻微变化。
JSON
{"a":0,"b":"foo","c":"23skidoo"}
URI编码的JSON
%7B%22a%22:0,%22b%22%3A%22foo%22%2C%22c%22%3A%2223skidoo%22%7D
Rison
(a:0,b:foo,c:'23skidoo')
URI编码的Rison
(a:0,b:foo,c:'23skidoo')
更多信息和其他实现,请参阅 http://mjtemplate.org/examples/rison.html。
使用方法
过程式/便利包装
require_once 'Rison/rison_functions.php'; $data = array('foo', 'bar' => array('baz')); // encoding $rison = Kunststube\Rison\rison_encode($data); var_dump($rison); // decoding $data = Kunststube\Rison\rison_decode($rison); var_dump($data);
面向对象
require_once 'Rison/RisonEncoder.php'; require_once 'Rison/RisonDecoder.php'; use Kunststube\Rison; $data = array('foo', 'bar' => array('baz')); // encoding try { $encoder = new Rison\RisonEncoder($data); $rison = $encoder->encode(); var_dump($rison); } catch (InvalidArgumentException $e) { echo $e->getMessage(); } // decoding try { $decoder = new Rison\RisonDecoder($rison); $data = $decoder->decode(); var_dump($data); } catch (Rison\RisonParseErrorException $e) { echo $e->getMessage(), ' in string: ', $e->getRison(); } catch (InvalidArgumentException $e) { echo $e->getMessage(); }
PSR-0
仓库组织方式使其内容可以倒入一个名为 Kunststube/Rison/
的文件夹中,并符合PSR-0命名规范。
信息
版本:0.92
作者:David Zentgraf
联系: rison@kunststube.net
许可证:公共领域