php-cjson - 基于 cjson 的 PHP 库
未知
跨平台
PHP
软件简介
php-cjson 是快速的 JSON 解析和生成的 PHP 库,基于 cjson 底层
C 库开发。
安装
$/path/to/phpize
$./configure --with-php-config=/path/to/php-config
$make && make install
示例
encode
$arr = array(
1,
"string",
array("key"=>"value")
);
var_dump(cjson_encode($arr));
/* ==>output
string(28) "[1,"string",{"key":"value"}]";
*/
decode
$str = '[1,"string",{"key":"value"}]';
var_dump(cjson_decode($str));
/* ==>output
array(3) {
[0]=>
int(1)
[1]=>
string(6) "string"
[2]=>
array(1) {
["key"]=>
string(5) "value"
}
}
*/