我正在try 使用以下行从post请求中获取数据:
$data = file_get_contents('php://input');
JSON字符串可能类似于:{"test" : "test one \xe0 "}
问题是,当我试着做json_decode($data)
分时,我得到了null
分.到var_dump()
年到$data
年,我看到一些像\xe0 \xe7a
这样的字符.
发送的数据是utf-8格式.我也用了utf8_decode($data)
个,但运气不好.有人能解释一下我错过了什么,或者如何解决这个问题吗?
我需要将无效的json转换为:
$data = '{"test" : "test one \xe0 "}';
致:
$data = '{"test" : "test one à "}';