fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <h2>从 JSON 字符串中创建一个对象</h2> <p id="demo"></p> <script> var text = '{"employees":[' + '{"name":"Fmpq教程","site":"http://www.fmpq.com" },' + '{"name":"Google","site":"http://www.Google.com" },' + '{"name":"Taobao","site":"http://www.taobao.com" }]}'; obj = JSON.parse(text); document.getElementById("demo").innerHTML = obj.employees[1].name + " " + obj.employees[1].site; </script> </body> </html>
运行结果