简单教程
提交运行
代码编辑器:
<h2>为 JSON 字符串创建对象</h2> <script> var text = '{ "sites" : [' + '{ "name":"Runoob" , "url":"www.runoob.com" },' + '{ "name":"Google" , "url":"www.google.com" },' + '{ "name":"Taobao" , "url":"www.taobao.com" } ]}'; obj = JSON.parse(text); document.write(obj.sites[1].name + " " + obj.sites[1].url); </script>
运行结果: