<!DOCTYPE html>
<html>
<body>
<h2>JSON Object Creation in JavaScript</h2>
<p>
Name: <span id="jname"></span><br />
Eval Name: <span id="evalname"></span><br />
<p>
<script>
var yyyy= {
"name":"John Johnson",
"street":"Oslo West 555",
"age":33,
"phone":"555 1234567"};
document.getElementById("jname").innerHTML = yyyy.name;
document.getElementById("evalname").innerHTML = eval(yyyy).name;
</script>
</body>
</html>
我要出来了,如下所示,无论有无 eval()
JavaScript 中的 JSON 对象创建
姓名:约翰·约翰逊
评估名称:约翰·约翰逊