zoukankan      html  css  js  c++  java
  • JSON解析

    <!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" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>Document</title>
        <script>
        var dog = {
            name: "Fido",
            dob: new Date(),
            legs: [1, 2, 3, 4]
        };
    
        var jsonstr = JSON.stringify(dog);
        console.log(jsonstr);//{"name":"Fido","dob":"2013-04-25T07:18:39.146Z","legs":[1,2,3,4]}
    
        var jstr = JSON.parse(jsonstr);
        console.log(jstr);// Object { name="Fido", dob="2013-04-25T07:18:39.146Z", legs=[4]}
        console.log(jstr.name);//Fido
        console.log(jstr.dob);//2013-04-25T07:18:39.146Z
        console.log(jstr.legs);//[1,2,3,4]
        console.log(jstr.legs[0]);//1
        </script>
    </head>
    <body>
        
    </body>
    </html>
  • 相关阅读:
    12.3
    团队项目第一阶段冲刺第一天
    4.22
    4.21 re重要功能
    12.1
    12.2
    4.17
    4.16
    css设置子元素相对于父元素保持位置不变(含有滚动条的父元素)
    git操作和npm操作清单
  • 原文地址:https://www.cnblogs.com/qzsonline/p/3042621.html
Copyright © 2011-2022 走看看