Json data is returned, and json_decode is left blank
Source: Internet
Author: User
Json data returned, after json_decode is empty http://zhidao.baidu.com/link? Url = response json data returned, which is blank after json_decode
Http://zhidao.baidu.com/link? Url = response
The problem I encountered is similar to that of him.
Call the app interface, and then php accepts the returned json string (the format is correct after verification): the returned data is inconsistent with the actual characters (three more characters ),
Change the php end to a json header or not
Returned by the app:
String (121 )"? {"ErrorCode": "0", "errorMsg": "success", "responseData": {"uid": "36", "sender_uid": "37 ", "error": "0", "error_msg": "success "}}"
Json_decode-> NULL
Copy to File:
String (118) "{" errorCode ":" 0 "," errorMsg ":" success "," responseData ": {" uid ":" 36 "," sender_uid ": "37", "error": "0", "error_msg": "success "}}"
------ Solution --------------------
Why is the BOM header?
------ Solution --------------------
The BOM header contains three more characters. you can remove it.
For example, if the received value is in $ s
$ A = json_decode (substr ($ s, 3 ));
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service