例子:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>json</title>
</head>
<body>
<h2>在JavaScript中创建JSON对象</h2>
<p>
Name:<span id="jname"></span><br />
Age:<span id="jage"></span><br />
Address:<span id="jstreet"></span><br />
Phone:<span id="jphone"></span><br />
</p>
</body>
</html>
<script type="text/javascript">
var JSONObject={"name":"liubeimeng","street":"beijing","age":"24","phone":"1234567"};
document.getElementById(‘jname‘).innerHTML=JSONObject.name;
document.getElementById(‘jage‘).innerHTML=JSONObject.age;
document.getElementById("jstreet").innerHTML=JSONObject.street;
document.getElementById("jphone").innerHTML=JSONObject.phone;
</script>