<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <script> var people = { "programmers":[ { "firstName":"Brett", "lastName":"McLaughlin", "email":"aaaa" }, { "firstName":"Jason", "lastName":"Hunter", "email":"bbbb" }, { "firstName":"Elliotte", "lastName":"Harold", "email":"cccc" } ], "authors":[ { "firstName":"Isaac", "lastName":"Asimov", "genre":"science fiction" }, { "firstName":"Tad", "lastName":"Williams", "genre":"fantasy" }, { "firstName":"Frank", "lastName":"Peretti", "genre":"christian fiction" } ], "musicians":[ { "firstName":"Eric", "lastName":"Clapton", "instrument":"guitar" }, { "firstName":"Sergei", "lastName":"Rachmaninoff", "instrument":"piano" } ] }; alert(people.programmers[0].lastName); //数组索引是从零开始,这行代码首先访问 people变量中然后移动到称为 programmers的条目,再移动到第一个记录([0]);最后,访问 lastName键的值。结果是字符串值 “McLaughlin”。的数据; alert(JSON.stringify(people)); //json序列化转字符串 //字符串的在线解析及序列换验证,参考json.cn </script> </body> </html>