Json2.js provides the JSON serialization (Json.stringify) and deserialization methods (Json.parse);
You can convert an object or array to a JSON string, or you can convert a JSON string into a JSON object.
Json2.js Source Address: Https://github.com/douglascrockford/JSON-js
Example of the last source network, use a look to understand,
The main explanation is
Json.stringify and Json.parse methods do not introduce json2.js under Ff,chrome, but in IE will error "json undefined", introduced json2.js resolution.
The string serialized by Json.stringify is received (PHP) on the server through Json_decode (str,true), and the second parameter, true, means to an array.
123<meta http-equiv="Content-type"Content="text/html; Charset=utf-8">4<title>json2</title>57<body>8<div id="msg"></div>9<div id="MSG2"></div>Ten<script src="Json2.js"Type="Text/javascript"></script> One<script type="Text/javascript"> A varuser={
-UserName:"Zhang San", -Sex:"male" the }; - varStr=json.stringify (user); -document.getElementById ("msg"). innerhtml="Serialization:"+str; - + varobj=json.parse (str); -document.getElementById ("MSG2"). innerhtml="deserialization:"+"Name:"+obj. UserName; +document.getElementById ("MSG2"). innerhtml+=" Gender:"+obj. Sex; A</script> at</body> -