相关函数
json_encode($data);//对变量进行JSON编码
json_decode($data,true)//对JSON格式的字符串进行解码
json_last_error();//返回最后一次反生的错误
基础用法
- json_decode
//mixed json_decode ( string $json [, bool $assoc ] ) //json待解码的 json string 格式的字符串。 //assoc当该参数为 TRUE 时,将返回array而非 object 。默认false $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; var_dump(json_decode($json)); var_dump(json_decode($json, true));