role: This function is mainly for the purpose of serialization objects.
Maybe some people are allergic to the word serialization, my understanding is very simple. This means converting the type of the object to a string type (or, more specifically, the JSON type). It's so simple. For example, you have a class, so you can convert it to the corresponding JSON type by this method. It's simple.
Then look.
Syntax:
Json.stringify (value [, Replacer] [, space])
Value: is the required field. Is the object you have entered, such as array Ah, class AH and so on.
Replacer: This is optional. It is divided into 2 ways, one is method, the second is an array.
begin to illustrate with examples;
<script type= "Text/javascript" src= "./js/customization/json2.js" ></script>
<script language= "JavaScript" > var t = json.parse (' {"name": 123} '); alert (t.name); var student = new Object (); Student.name = "Lanny"; Student.age = ""; student.location = "China", var ar = new Array (), for (var i = 0; i<8;i++) { var elelem = new Object (); elelem.name = ' AA ' +i; elelem.age = ' BB ' +i; Ar.push (Elelem);} Student.par = AR; var json = json.stringify (student); alert (student); alert (JSON); </script>
Json.stringify Grammar Explanation