There is no "JSON" object at all (read Uncle Tom's blog post record)

Source: Internet
Author: User

1. Literal quantity

(1) They are fixed values, not variables, that allow you to "literally" understand the script.

(2) string literals are composed of 0 or more strings surrounded by double quotation marks ("") or single quotation marks ("").

(3) The object literal is a property (Key-value pair) of 0 or more objects enclosed by curly braces ({}).

2, when is JSON, when is not JSON

JSON is designed to describe the data interchange format, and he also has his own syntax, which is a subset of JavaScript.

{"Proporty": "Value"} such a declaration may be either a JavaScript object literal or a JSON string, depending on what context uses it, if it is in a string context (in single or double quotation marks, or from a text file), Then it is the JSON string, and if it is in the context of the object literal, it is the object literal.

// This is a JSON string var str = ' {' Proporty ': ' Value '} '; // This is the object literal . var obj = {"Proporty": "Value"};

Also note that JSON has a very strict syntax, in the string context {"proporty": "Value"} is a valid JSON, but {proporty: "Value"} and {' Proporty ': ' Value '} is indeed illegal. All property names and their values must be enclosed in double quotation marks and cannot be used in single quotes. In addition, even if you use the escape after the single quotation mark is also illegal, the detailed syntax rules can be viewed here.

There is no JSON object at all (read Uncle Tom's blog entry)

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.