The first: The browser supports conversion mode (Firefox, chrome, opera, safari, ie) and other browsers:
The JSON.parse (jsonstr); // can be converted into a string json json objects the JSON.stringify (jsonobj); // can be converted into json json objects of the string
The second: Javascript support conversion:
the eval ( '(' + jsonstr + ')'); // can be converted into a string json json objects, attention needs to wrap a pair of small outer json parentheses characters NOTE: ie8 (compatibility mode), may also be used ie6 IE7 and eval () the string to a JSON object, but does not recommend these methods, this approach will perform unsafe eval expression json string.
Third: jQuery plug-in support conversion:
.parseJSON $ (jsonstr); // jQuery.parseJSON (jsonstr), can be converted into a string json json objects
Fourth: This rather special, using a Function ():
var STR = '{ "name": "man"}' ; var JSON = ( new new Function ( "return" + STR)) (); // here to be noted that there is the last (); the console.log ( json);
The first: The browser supports conversion mode (Firefox, chrome, opera, safari, ie) and other browsers:
The JSON.parse (jsonstr); // can be converted into a string json json objects the JSON.stringify (jsonobj); // can be converted into json json objects of the string
The second: Javascript support conversion:
the eval ( '(' + jsonstr + ')'); // can be converted into a string json json objects, attention needs to wrap a pair of small outer json parentheses characters NOTE: ie8 (compatibility mode), may also be used ie6 IE7 and eval () the string to a JSON object, but does not recommend these methods, this approach will perform unsafe eval expression json string.
Third: jQuery plug-in support conversion:
.parseJSON $ (jsonstr); // jQuery.parseJSON (jsonstr), can be converted into a string json json objects
Fourth: This rather special, using a Function ():
var STR = '{ "name": "man"}' ; var JSON = ( new new Function ( "return" + STR)) (); // here to be noted that there is the last (); the console.log ( json);