PHP JSON

JSON 编码

json_encode ( mixed $value [, int $options = 0 [, int $depth = 512 ]] ) : string

JSON常量: https://www.php.net/manual/zh/json.constants.php

常用常量
让URL内容斜杠/不转义 JSON_UNESCAPED_SLASHES
中文编码 JSON_UNESCAPED_UNICODE

JSON解析

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

json
待解码的 json string 格式的字符串。
这个函数仅能处理 UTF-8 编码的数据。
assoc
当该参数为 TRUE 时,将返回 array 而非 object 。
depth
指定递归深度。
options
JSON解码的掩码选项。 现在有两个支持的选项。 第一个是JSON_BIGINT_AS_STRING, 用于将大整数转为字符串而非默认的float类型。第二个是 JSON_OBJECT_AS_ARRAY, 与将assoc设置为 TRUE 有相同的效果。

强制解析为数组

json_decode($str,TRUE) 

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 lzdong@foxmail.com

×

喜欢就点赞,疼爱就打赏