JSON object for JavaScript

Source: Internet
Author: User

JSON = JavaScript Object notation

What is JSON

The text format of the data interchange, simply stated, is that each JSON object is a value, either a value of a simple type or a value of a composite type, but only one value, not two or more values, which means that each JSON document can contain only one value.

The advantages of JSON

Writing is simple, at a glance, in line with JavaScript native syntax and can be handled directly by the interpretation engine without adding additional parsing code.

JSON data types and formatting rules

· The value of a composite type can only be an array or an object, not a function, a regular expression object, or a Date object.

· There are only four values for a simple type: string, numeric value (must be represented in decimal), Boolean, and Null (cannot use nan,infinity,-infinity,undefined).

· The string must be in double quotation marks, cannot use single quotation marks ["One", "two", "three"]

· The key name of the object must be enclosed in double quotation marks {"One": 1, "two": 2, "three": 3} {"Names": ["Zhang San", "John Doe"]}

· After the last member of an array or object, you cannot add a comma [{"Name": "Zhang San"},{"name": "John Doe"}]

Two methods of JSON ( json.stringify () and Json.parse () )

Json.stringify () is used to convert a value to a string. The string should be in JSON format and can be restored by the Json.parse () method.

JSON object for JavaScript

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.