• 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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    
    <script>
    var people = {
        "programmers":[
            {
                "firstName":"Brett",
                "lastName":"McLaughlin",
                "email":"aaaa"
            },
            {
                "firstName":"Jason",
                "lastName":"Hunter",
                "email":"bbbb"
            },
            {
                "firstName":"Elliotte",
                "lastName":"Harold",
                "email":"cccc"
            }
        ],
        "authors":[
            {
                "firstName":"Isaac",
                "lastName":"Asimov",
                "genre":"science fiction"
            },
            {
                "firstName":"Tad",
                "lastName":"Williams",
                "genre":"fantasy"
            },
            {
                "firstName":"Frank",
                "lastName":"Peretti",
                "genre":"christian fiction"
            }
        ],
        "musicians":[
            {
                "firstName":"Eric",
                "lastName":"Clapton",
                "instrument":"guitar"
            },
            {
                "firstName":"Sergei",
                "lastName":"Rachmaninoff",
                "instrument":"piano"
            }
        ]
    };
    alert(people.programmers[0].lastName);  
    //数组索引是从零开始,这行代码首先访问 people变量中然后移动到称为 programmers的条目,再移动到第一个记录([0]);最后,访问 lastName键的值。结果是字符串值 “McLaughlin”。的数据;
    alert(JSON.stringify(people)); 
    //json序列化转字符串
    //字符串的在线解析及序列换验证,参考json.cn
    </script>
    </body>
    </html>
  • 相关阅读:
    Vue如何下载文件?
    vue用template还是JSX?
    2020年的第一件事,我取关了97个公众号
    月经贴 | 2019.12
    CSS——盒子模型(含详解)
    CSS——字体、文本、背景属性设置
    CSS——选择器(三大特性)
    CSS——选择器(本篇介绍八类多种)
    CSS——简介
    WEB前端——body内常用标签(form标签)
  • 原文地址:https://www.cnblogs.com/vscss/p/5673255.html
Copyright © 2020-2023  润新知