我得到JSON字符串:json_decode返回 「NULL」 幫我
$response = '{"retcode":"0","retmsg":"OK","cre_id_enc":"","cre_type":"","fee_type":"1","listid":"1221085301201410240000001024","out_trade_no":"201410246763831","partner":"1221085301","pay_fee":"0","sign":"PTamau\x2BjkynA00cASKJ6Nd3QwFSBP44TKSqmmdCd\x2F\x2B0o8ViSt3fp5vQr0Fc73U42NhtImfnHzbynoUjURiNLW5O4hI61xkG\x2F97JRPRE0nHuvtAumqXfbVCsLveugE52HRZsJvm3EG7pL6GlhYf8ng6qxiUrDyn89PFVZ04Wd8Gk\x3D","total_fee":"1000000","unfreeze_fee":"1000000","user_name_enc":""}';
我用json_decode這個字符串轉換爲數組,但它返回 「NULL」。我找到不能使用json_decode。它包含ASCII碼如'\ x2F','\ x2B','\ x3D'。 所以我嘗試轉換爲utf8,像這樣$response = iconv('ASCII', 'UTF-8//IGNORE', $response);
。 它沒有用。響應字符串仍然包含'\x2F' , '\x2B', '\x3D'
和json_decode
仍然返回NULL。
有人可以幫助我,原諒我可憐的英語! 謝謝!
謝謝!我發現'$ json = str_replace('\ x','\\\\ x',$ response);'是對的 – GiGi 2014-10-27 03:41:38