介绍
JSONLite是JSON的简化版。减少字符输出的同时,仍保持数据有效性。
建议PHP版本>=5.2.0。
特性Js兼容模式,兼容Js语法。取消了不必要的双引号。
Strict强类型模式,提供强类型输出与解析,可用于与强类型语言通讯。
如1.0序列化和解序列后的类型均为double,不会转换为it1。
Mi最小化模式,最小化输出数据,可用于日志打印。
较为精确的错误位置和信息提示。
解析时更为显性的暴漏格式错误
示例代码:
$value=array('code'=>'123','msg'=>'truestr','ull'=>ull,'ew'=>'','double'=>1.0,);//serialize//jsechojsolite_ecode($value);//{code:123,msg:"truestr","ull":0,"ew":"",double:1}//miechojsolite_ecode($value,JSONLITE_MODE_MIN);//{code:123,msg:truestr,"ull":,ew:,double:1}//strictechojsolite_ecode($value,JSONLITE_MODE_STRICT);//{code:"123",msg:truestr,"ull":ull,ew:,double:1.0}//userialize$jsolite='{code:123,msg:truestr,"ull":ull,ew:,double:1}';$value=jsolite_decode($jsolite);var_export($value);/***array(*'code'=>123,*'msg'=>'truestr',*'ull'=>NULL,*'ew'=>'',*'double'=>1,*)*///workwithjso$value=array('code'=>'123','msg'=>'truestr','ull'=>ull,'ew'=>'','double'=>1.0,);$jso=jso_ecode($value);//ATTENTION:ecodewithjso//{"code":"123","msg":"truestr","ull":ull,"ew":"","double":1}$value=jsolite_decode($jso);var_export($value);/***array(*'code'=>123,*'msg'=>'truestr',*'ull'=>NULL,*'ew'=>'',*'double'=>1,*)*/体积对比根据测试数据计算,实际情况请另行估算。
模式JSONJSONLite变化量变化率array_js929200.00%array_strict9274-1819.57%array_mi9270-2223.91%map_js11197-1412.61%map_strict11183-2825.23%map_mi11181-3027.03%









评论