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)