Json cannot be parsed

Source: Internet
Author: User
Json cannot be parsed to ask everyone a question. a function is provided on the website to load third-party files and send text messages. The text message is sent successfully, and array ('status' => 0, 'message' => 'sent successfully') is returned in the form of a json string. in this case, the returned json string cannot be parsed. if you remove the text message, then the returned json string can be parsed normally, and no difference is found between the normal string and the strings that cannot be parsed.


Reply to discussion (solution)

Whether it is the reason for BOM header
It is best to post the returned json string encoded with base64_encode

Whether it is the reason for BOM header
It is best to post the returned json string encoded with base64_encode



Is this base64_encode encoded string? EyJzdGF0dXMiOjEsIm1lc3NhZ2UiOiIxMjM1In0 =

You should post the base64 encoding of the json string that cannot be parsed!

You should post the base64 encoding of the json string that cannot be parsed!



? {"Status": 1, "message": "\ u5347 \ u7ea7 \ u4e2d \ uff01"} the json string cannot be parsed and is prompted in the json parsing tool, however, after you paste the json string in word and copy it to the json parsing tool, the resolution is successful.

Copy string? {"Status": 1, "message": "\ u5347 \ u7ea7 \ u4e2d \ uff01"} http://www.bejson.com to the json parsing tool/Failed to parse the prompt Unexpected token? Error

You should post the base64 encoding of the json string that cannot be parsed!

? EyJzdGF0dXMiOjEsIm1lc3NhZ2UiOiIxMjM1In0 = this string is a base64 encoded string when json cannot be parsed.

You are still not correct!

$s = base64_decode('eyJzdGF0dXMiOjEsIm1lc3NhZ2UiOiIxMjM1In0=');print_r(json_decode($s));
stdClass Object(    [status] => 1    [message] => 1235)

It can be explained that what you post is not the incorrect json

 



Array
(
[Status] => 1
[Message] => upgrading!
)

Copy string? {"Status": 1, "message": "\ u5347 \ u7ea7 \ u4e2d \ uff01"} http://www.bejson.com to the json parsing tool/Failed to parse the prompt Unexpected token? Error



This tool is problematic when processing json separately, so the json string you provide is correct.

After reading some of the upstairs statements, I suddenly felt that your front-end jquery code was wrong.

$ Url = 'http: // bbs.csdn.net/topics/391832102'{s S = file_get_contents ($ url); $ w = iconv ('gbk', 'utf-8', 'copy string '); // I used to use the gbk environment preg_match ("/$ w (. +})/", $ s, $ m); echo bin2hex ($ m [1]), PHP_EOL; echo substr ($ m [1], 3 );
efbbbf7b22737461747573223a312c226d657373616765223a225c75353334375c75376561375c75346532645c7566663031227d{"status":1,"message":"\u5347\u7ea7\u4e2d\uff01"}
Isn't efbbbf the BOM header?

Come and come, preview and verify the data, and simulate the request
Http://jsonohyeah.com

Thank you for your enthusiastic answers. maybe there is a problem with the tool I used.

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.