Introduction to JSON and summary

Source: Internet
Author: User

1. What's the JSON?

JavaScript Object Notation (JavaScript objects Notation). JSON is a lightweight format for data interchange. For example, inside a JSON-formatted file, this can be:

{

"Name": "Zhangsan",

"Sex": "Male"

}

Looks much like Key-value's key-value pairs, very line JS object. But JSON is not satisfied, he has to have his own personality, so the key-value pair of keys must be in double quotation marks! At the same time, it is necessary to specify the value of the key-value correspondence:

The value of JSON allows you to:

1) Number (certificate or floating point)

2) string (in double quotes)

3) Logical value (TRUE or FALSE)

4) Array (in square brackets)

5) object (in curly braces)

6) NULL

Out of the above, no other, no like JS underfined, NAN, JSON refused to use.

2. If the properties of a JSON object are an array object, such as and get the properties of an array object?

Note: Never use the properties of an array object to get the properties of an array object, especially when there is only one object property in the array object, which is very confusing. If you have the properties of the array object property to get

The value of the array object, if there are multiple objects inside the array object, which of the properties of the array object do you actually get? or the design of the designer. So the proper way to get the property of the array formation is to iterate through the array and then traverse

Gets the value of the array object for each object's properties.

3. How to use JSON

JSON is generally based on the shape of the string in the process of data interaction, so for JS, how to convert the JSON string and JS object between each other is particularly important.

Json.parse (JSON string------------->>>>>>>>>>js object) Parse parse JSON parse is to convert the JSON string to J S object.

Json.stringify (JS object--------------->>>>>>>>>>json String)

4. It has always been thought that many of the interfaces that call others are failures, and the test of how successful the data is made. is to call the other person's interface or, return the parameters to overwrite the returned parameters.

Introduction to JSON and summary

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.