简化版的JSONJSONLite.zip

时间:2022-08-05 01:45:27
【文件属性】:
文件名称:简化版的JSONJSONLite.zip
文件大小:360KB
文件格式:ZIP
更新时间:2022-08-05 01:45:27
开源项目 介绍 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% 标签:JSONLite 分享 window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": [], "bdPic": "", "bdStyle": "1", "bdSize": "24" }, "share": {} }; with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' ~(-new Date() / 36e5)];\r\n \r\n \r\n \r\n \r\n \u8f6f\u4ef6\u9996\u9875\r\n \u8f6f\u4ef6\u4e0b\u8f7d\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\nwindow.changyan.api.config({\r\nappid: 'cysXjLKDf', conf: 'prod_33c27aefa42004c9b2c12a759c851039' });
【文件预览】:
php-jsonlite-master
----.gitignore(21B)
----README.md(3KB)
----config.m4(678B)
----diagram()
--------array.png(15KB)
--------map_or_object.png(21KB)
--------value.png(32KB)
--------diagram.js(4KB)
--------string.png(288KB)
--------number.png(17KB)
----jsonlite_decode.c(20KB)
----helper.h(1KB)
----tests()
--------decode-array.phpt(1KB)
--------encode-bool.phpt(295B)
--------001.phpt(103B)
--------decode-bool.phpt(281B)
--------decode-error.phpt(2KB)
--------decode-null.phpt(220B)
--------encode-array.phpt(1KB)
--------encode-object.phpt(2KB)
--------encode-error.phpt(602B)
--------encode-null.phpt(225B)
--------decode-number.phpt(525B)
--------encode-number.phpt(434B)
--------encode-string.phpt(1KB)
--------helper.php(3KB)
--------decode-string.phpt(1KB)
--------decode-object.phpt(3KB)
----api()
--------jsonlite_encode.php(1KB)
--------jsonlite_decode.php(1KB)
----jsonlite_encode.h(2KB)
----php()
--------tests()
--------jsonlite.php(21KB)
----jsonlite_encode.c(15KB)
----php_jsonlite.h(2KB)
----CREDITS(37B)
----helper.c(2KB)
----jsonlite.c(5KB)
----jsonlite.php(505B)
----.travis.yml(319B)
----EXPERIMENTAL(0B)
----jsonlite_decode.h(2KB)

网友评论