//20.1 syntax // JAVASCRIPT is JSON data supports. // JSON may be simply stated value of three types of values ( "hello world") Object ({ "name": "maosi "}) array ([ "A", "B", "C"]) //20.1. 2 json objects var Person = { "name": "Nicholas", "Age": 29}; Person = { "name": "Nicholas", "Age": 29, "School": { "name": "Merrimack College ", " LOCATION ":" North Andover, MA " } } // JS objects var Person = {name:" Nicholas ", Age: 29}; //20.1.3 array (js json array with the same syntax) var values = [25, 'hi', true]; ], jsontext = JSON.stringify(book, ["title", "edition "]); // attribute represents an array of sequence (a sequence of attributes which specify only) Edition:. 3, year: 2011 }, { "title": "Professnional JavaScript", "the authors": [ "C Zakas Nicholas" ], Edition: 2, year: 2009 } ] //20.2 serialization and parsing // sequence of var = {Book title: "Professional the JavaScript", the authors: [ "C Zakas Nicholas"], Edition:. 3, year: 2011, releaseDate: new new a Date (2011,1,1); }; var = jsontext the JSON.stringify (Book); //20.2.2 serialization options // attribute logic processing sequence jsontext = JSON.stringify (book, function ( key, value) { Switch (Key) { Case "the authors": return value.JSON ( ','); Case "year": return 5000; Case "Edition": return undefined; // undefined is defined herein as the sequence of the string when this field is ignored, the ignore default: return value; } }); // indentation JSON string, the method described above into a row long sequence will JSON string jsontext = JSON.stringify (book, null, 4); // the third parameter indicates the number of spaces for each indent level the JSON.parse (jsontext, function (Key, value) { IF (Key == 'releaseDate') { return new new a Date (value); // for a particular object restore operation string } the else { return value; } }); //20.3 Summary