json_decode使用

来源:互联网 发布:无法启用网络发现 编辑:程序博客网 时间:2024/06/16 03:35

json_decode对 JSON 格式的字符串进行编码


说明

mixedjson_decode( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )

接受一个 JSON 格式的字符串并且把它转换为 PHP 变量 


参数

json

待解码的 json string格式的字符串。

This function only works with UTF-8 encoded data.

assoc

当该参数为 TRUE 时,将返回 array 而非 object

depth

User specified recursion depth.

options

Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRINGis supported (default is to cast large integers as floats)

返回值


assoc设置为true时返回数组,false时返回对象。

Returns the value encoded in json in appropriate PHP type. Valuestrue, false and null (case-insensitive) are returned asTRUE , FALSE and NULL respectively. NULL is returned if thejson cannot be decoded or if the encoded data is deeper than the recursion limit. 


0 0
原创粉丝点击