原型——雜湊.JSON() 方法



此方法會返回一個 JSON 字串。

語法

hash.toJSON();

返回值

返回一個 JSON 字串。

示例

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         function showResult() {
            var h = new Hash({ a: 'apple', b: 'banana', c: 'coconut' });
            alert( "h.toJSON() : " + h.toJSON() );
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br />
      <br />
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

輸出

prototype_json_tutorial.htm
廣告
© . All rights reserved.