简体   繁体   English

从POST数据解码时,json_decode JSON_ERROR_UTF8错误

[英]json_decode JSON_ERROR_UTF8 error when deecoding from POST data

This code works fine for me 这段代码对我来说很好

 $input= '{"remoteRef":"RM4","competitionName":"Calgary 2012 - IVF World Sprint Champs","venue":"Calgary, Canada","startDate":"2012-08-11T00:00.00","finishDate":"2012-08-11T00:00.00","races":[{"remoteRef":"1001-0010303","raceNo":"216","eventName":"Adaptive Mixed - V6 500","roundName":"St. Final","roundNo":1,"roundCount":1,"scheduledStart":"2012-08-13T13:36.00","actualStart":"2012-08-13T14:28.08","isFinal":true,"lanes":[{"laneNo":"1","teamName":"Hawaii # 2","clubName":"Hawai\u0027i","placing":"3","officialTime":"3:00.58","officialTimeMs":86580580},{"laneNo":"2","teamName":"Rio Va´a","clubName":"Brazil","placing":"2","officialTime":"2:46.66","officialTimeMs":86566660},{"laneNo":"3","teamName":"Hawaii # 1","clubName":"Hawai\u0027i","placing":"1","officialTime":"2:46.43","officialTimeMs":86566430}],"raceState":"RESULT"}]}';

 $json = json_decode($input);

 var_dump($json);

But when I post the same data to my website and use the code below. 但是,当我将相同的数据发布到我的网站并使用下面的代码时。 I get a json decode error JSON_ERROR_UTF8 我收到JSON解码错误JSON_ERROR_UTF8

$input = file_get_contents('php://input');

$json = json_decode($input);

var_dump($json);

Any ideas what I could be doing wrong to get that JSON_ERROR_UTF8 error? 任何想法我可能会做错什么才能得到JSON_ERROR_UTF8错误?

在发布前尝试base64编码,在获取后解码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM