<!DOCTYPE HTML> <html> <head> <title>Javasctipt JSON.stringify()</title> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <script type="text/javascript"> function main() { var obj = {}; obj.foo = 'bar'; obj.baz = [0, 1, 2, 3]; var json = JSON.stringify(obj); document.getElementById('out').innerHTML = json; // {"foo":"bar","baz":[0,1,2,3]} } </script> </head> <body onload="main();"> <div id="out"></div> </body> </html>
JSON
object.