There are many conversion methods between Json characters and Json objects. Next we will introduce them one by one. If you are interested, please refer to the following:
1> conversion modes supported by jQuery plug-in:
The Code is as follows:
$. ParseJSON (jsonstr); // jQuery. parseJSON (jsonstr), which can convert a json string to a json object
2> conversion modes supported by browsers(Firefox, chrome, opera, safari, ie9, ie8) and other browsers:
The Code is as follows:
JSON. parse (jsonstr); // you can convert a json string to a json object.
JSON. stringify (jsonobj); // you can convert a json object to a json string.
Note: For ie8 (compatible mode), ie7 and ie6 do not have JSON objects. We recommend using the official JSON method to introduce json. js.
3> conversion modes supported by Javascript:
Eval ('+ jsonstr +'); // you can convert a json string to a json object. Enclose a pair of parentheses outside the json character.
Note: ie8 (compatible mode), ie7 and ie6 can also convert strings into JSON objects using eval (), but these methods are not recommended, this method is not secure. eval executes the expression in the json string.
4> official JSON Conversion Method:
Http://www.json.org/with A json.js, this IE8 (compatible mode), ie7 and ie6 can support the JSON object and its stringify () and parse () methods;
You can.