JSON Standard: double quotes rather than single quotes!

Source: Internet
Author: User

Just testing found a simple, seemingly correct code that was wrong:

<?  "{' name ': ' Eric ', ' age ': +}"


As you know, the PHP version has added two JSON-capable functions since 5.2.0, namely Json_encode and Json_decode, where the Json_decode function converts the JSON string to a JSON object, as shown in the previous example. But the output of the above example is null, that is, the conversion failed. This is why, Baidu, some people say that PHP's two functions of the JSON support is not completely caused by the solution is written in the following form:

<?  '{' name ': ' Eric ', ' age ': all,}';   // //

Just change the single quote to double quotes, but is this really a mistake for PHP? Then on the JSON official website found that the double quotation marks is the standard JSON, single quotation marks are not standard (although in JS is the line of the pass)! So everyone in the future to develop a habit, the name of the JSON and string values are quoted in double quotes ~

Transferred from: http://www.lanrenmaku.com/JSON/2014_1116_1294.html

JSON Standard: double quotes rather than single quotes!

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.