梦之都
JavaScript教程
eval
函数,使用eval解析json对象
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>eval函数解析json对象</title> </head> <body> <script type="text/javascript"> var json=eval("({sitename:'dreamdu',sitedate:new Date(1980, 12, 17, 12, 0, 0)})"); document.write(json.sitename); document.write("<br />"); document.write(json.sitedate); </script> </body> </html>