1、JSON.stringify()
例子:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <script src='jquery-1.6.1.js'></script> <title></title> </head> <body> </body> <script> var clock={ hour:12, minute:10, second:10, showTime:function(){ } } alert(JSON.stringify(clock)); </script> </html>
2、JSON.parse()
例子:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <script src='jquery-1.6.1.js'></script> <title></title> </head> <body> </body> <script> var clock={ hour:12, minute:10, second:10, showTime:function(){ } } alert(JSON.parse(JSON.stringify(clock))); </script> </html>
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-05 19:40:01