JavaScript Advanced Programming Chapter 20th JSON notes (study notes)

Source: Internet
Author: User

20th ChapterJSON1.Jsonyou can represent three types of values:1.Simple values:

Represents a numeric value:5 represents a string: "Hello wrold" note must use double quotation marks when representing a string

2.object:

{"name":"mi","age": 24} with the JavaScript object has two different one is not declared variable two is not the end of the semicolon JSON object property must be quoted, the value within the object can be nested objects.

3. Arrays

JSON array representation:[ + , "Hi", true] json as JSON object There are no semicolons and no variables.

2.json Objects

1.Stringify ()method is used to putJavscriptobject is serialized asJSONstring

1. syntax var newjson=json. Stringify ( data that needs to be converted ) All function prototypes are ignored during the conversion, and properties with a value of undefined are skipped.

2.Stringify () In addition to the serialized JS object can also accept two parameters, these two parameters are used to specify a different way to serialize the object, the first parameter is a filter, can be an array or can be a function, The second parameter is an option that indicates whether to keep the lock in the json string

2.Parse ()method is used to putJSONstring parsing to nativeJSvalue;If the method is not passed to a validJSOwill throw an error,

Parse () can also accept another parameter, which is a function that takes two arguments, one is a key (property), and the other is a value

3.toJSON ()Method

You can give a JSON data format that defines the Tosojson () method for the image to return itself .

21st ChapterAjax

JavaScript Advanced Programming Chapter 20th JSON notes (study notes)

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.