绝大多数时候不是 jsON 格式错了,而是编码或 bom 头干扰了 json_decode() 的解析。php 对 UTF-8 BOM 非常敏感,哪怕字符串开头多了 ,json_decode() 就直接返回 null,且不报错。
json_decode()
null
trim($json, "