1.json.parse; Function: Converts a JSON string of JavaScript Object notation to an object (string to object).
Syntax : json.parse (text [, Reviver]) text must be selected.
A valid JSON string.
Reviver is optional.
A function that transforms the result.
This function is called for each member of the object.
return value : JSON object.
Instance:
1 var jsonstr = ' {' SiteName ': "Web Development", "url": "Www.baidu.com"} ' ; 2 var jsonobj = json.parse (jsonstr); 3 alert (typeof//Object
2.json.stringify
Purpose : Converts a JavaScript JSON object into a JSON string of JavaScript Object notation (the object is converted to a string).
Syntax : json.stringify (value [, Replacer] [, space]); Value required a function or array space that is typically replacer an optional conversion result for an object or array is optional. Adding indents, whitespace, and newline characters returns the value of the JSON text for easier reading.
If space is omitted, the return value text is generated without any additional whitespace.
If space is a number, the return value has a blank text indent for the specified number at each level.
If space is greater than 10 o'clock, the text indents 10 blanks. If space is a non-empty string, such as "\ T", the return value text is indented with the character of the string at each level.
If space is a string greater than 10 characters, the first 10 characters are used.
return value : The text string that the JSON contains.
Instance:
1 var New Object (); 2 site.name = "web Development"; 3 site.url= "www.baidu.com"; 4 var jsonsite = json.stringify (site); 5 alert (typeof//string
The above method only supports ie8+, if you want to support ie6,7, refer to:http://www.json.cn/
Of course, you can also use jquery's Parsejson method.
< reference:http://www.kuaipao8.com/?p=1257>
The parse () and Stringfy () methods of JSON