json_decode
语法:json_decode ($json [,$assoc = false [, $depth = 512 [, $options = 0 ]]])
- $json 为待解码的数据,必须为utf8编码的数据;
- $assoc 值为TRUE时返回数组,FALSE时返回对象;(调用返回数据的值时会不一样)
- $depth 为递归深度;
- $option 二进制掩码,目前只支持 JSON_BIGINT_AS_STRING;(一般用不到)
- 一般只用前面两个参数,如果要数据类型的数据要加一个参数true。
json_encode
json_encode() 对变量进行JSON编码
语法: json_encode ( $value [, $options = 0 ] )
- $value为要编码的值,且该函数只对UTF8编码的数据有效;
- 第二个参数一般不需要;
- 执行成功返回JSON数据,否则返回FALSE。