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>
  • 相关阅读:
    threading学习
    Python基础-5
    BS4
    requests基础
    Python基础-4
    Python基础-3
    Python基础-2
    Python基础-1
    DevOps
    nginx配置ssl证书实现https
  • 原文地址:https://www.cnblogs.com/qzsonline/p/3042621.html
Copyright © 2011-2022 走看看