简化版的JSON JSONLite
- 授权协议: GPL
- 开发语言: PHP
- 操作系统: 跨平台
- 软件首页: https://github.com/eixom/php-jsonlite
- 软件文档: https://github.com/eixom/php-jsonlite
软件介绍
介绍
JSONLite 是 JSON 的简化版。减少字符输出的同时,仍保持数据有效性。
建议PHP版本 >= 5.2.0 。
特性
-
Js 兼容模式,兼容Js语法。取消了不必要的双引号。
-
Strict 强类型模式,提供强类型输出与解析,可用于与强类型语言通讯。
-
如 1.0 序列化和解序列后的类型均为 double,不会转换为 int 1。
-
Min 最小化模式,最小化输出数据,可用于日志打印。
-
较为精确的错误位置和信息提示。
-
解析时更为显性的暴漏格式错误
示例代码:
$value = array(
'code' => '123',
'msg' => 'true str',
'null' => null,
'new' => '',
'double' => 1.0,
);
// serialize
// js
echo jsonlite_encode($value);
// {code:123,msg:"true str","null":0,"new":"",double:1}
// min
echo jsonlite_encode($value, JSONLITE_MODE_MIN);
// {code:123,msg:true str,"null":,new:,double:1}
// strict
echo jsonlite_encode($value, JSONLITE_MODE_STRICT);
// {code:"123",msg:true str,"null":null,new:,double:1.0}
// unserialize
$jsonlite = '{code:123,msg:true str,"null":null,new:,double:1}';
$value = jsonlite_decode($jsonlite);
var_export($value);
/**
* array (
* 'code' => 123,
* 'msg' => 'true str',
* 'null' => NULL,
* 'new' => '',
* 'double' => 1,
* )
*/
// work with json
$value = array(
'code' => '123',
'msg' => 'true str',
'null' => null,
'new' => '',
'double' => 1.0,
);
$json = json_encode($value); // ATTENTION:encode with json
// {"code":"123","msg":"true str","null":null,"new":"","double":1}
$value = jsonlite_decode($json);
var_export($value);
/**
* array (
* 'code' => 123,
* 'msg' => 'true str',
* 'null' => NULL,
* 'new' => '',
* 'double' => 1,
* )
*/
体积对比
根据测试数据计算,实际情况请另行估算。
| 模式 | JSON | JSONLite | 变化量 | 变化率 |
| array_js | 92 | 92 | 0 | 0.00% |
| array_strict | 92 | 74 | -18 | 19.57% |
| array_min | 92 | 70 | -22 | 23.91% |
| map_js | 111 | 97 | -14 | 12.61% |
| map_strict | 111 | 83 | -28 | 25.23% |
| map_min | 111 | 81 | -30 | 27.03% |
Paradigms of Artificial Intelligence Programming
Peter Norvig / Morgan Kaufmann / 1991-10-01 / USD 77.95
Paradigms of AI Programming is the first text to teach advanced Common Lisp techniques in the context of building major AI systems. By reconstructing authentic, complex AI programs using state-of-the-......一起来看看 《Paradigms of Artificial Intelligence Programming》 这本书的介绍吧!
