JSON data returned, empty after Json_decode

Source: Internet
Author: User
Http://zhidao.baidu.com/link?url=kEYMQrLi41ZyC3Yo5XoN_QEbUentL2yVvcUg3seg_ZVksV2w5KBMudlQomrizXZiEoe3Uz0xtp7Moj9nRLBLNK

I have the same problem as him.

Call the app interface, and then PHP accepts the return JSON string (well-formed after validation): The returned data does not match the actual character (three characters more),
And then change the PHP to a JSON header or not.
The app returns:
String (121) "? {"ErrorCode": "0", "errormsg": "Success", "ResponseData": {"UID": "$", "Sender_uid": "PNs", "Error": "0", "error_msg": " Success "}}"
Json_decode->null
Copied to the file:
String (118) "{" ErrorCode ":" 0 "," errormsg ":" Success "," ResponseData ": {" UID ":" $ "," Sender_uid ":" PNs "," Error ":" 0 "," Error_msg ":" Success "}}"


Reply to discussion (solution)

BOM Header reasons for it

More than three characters are BOM head, remove on it can be
For example, if received in the $s, then
$a = Json_decode (substr ($s, 3));

More than three characters are BOM head, remove on it can be
For example, if received in the $s, then
$a = Json_decode (substr ($s, 3));
Go to the company tomorrow and try it.

More than three characters are BOM head, remove on it can be
For example, if received in the $s, then
$a = Json_decode (substr ($s, 3));

With the Baidu push sent, and looked for several hours, the original Baidu a document with BOM head, Egg pain dead!!! Thank you.

BOM Header reasons for it
All right, thank you.


Recommend a JSON format tool, JSON validation tool, http://www.sojson.com

No Ads loaded fast tools

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.