• JOSN反串行化


    JOSN编码的数据可以使用eval函数生产操作的类型。

    <%@ Page Language="C#" %>
    
    <!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 runat="server">
        <title></title>
        <script type="text/javascript">
            var JSONstring = '{' +
                '"artist" : "Phish",' +
                '"title" : "A Picture of Nectar",' +
                '"releaseYear" : 1992,' +
                '"tracks" :  [' +
                ' "Llama",' +
                ' "Eliza",' +
                ' "Cavern",' +
                ' "Poor Heart",' +
                ' "Stash",' +
                ' "Manteca",' +
                ' "Guelah Papyrus",' +
                ' "Magilla",' +
                ' "The Landlady",' +
                ' "Glide",' +
                ' "Tweezer",' +
                ' "The Mango Song",' +
                ' "Chalk Dust Torture",' +
                ' "Faht",' +
                ' "Catapult",' +
                ' "Tweezer Reprise",' +
                ']' +
            '}';
    
            function pageLoad() {
                var album = eval("(" + JSONstring + ")");
                var innerHTML = "artist = " + album.artist + "<br />" +
                    "title = " + album.title + "<br />" +
                    "releaseYear = " + album.releaseYear;
                $get('placeholder').innerHTML = innerHTML;
    
                var tracks = "";
                for (var i = 0; i < album.tracks.length; i++) {
                    tracks += "tracks #" + i + " = " + album.tracks[i] + "<br />";
                }
    
                $get('placeholder2').innerHTML = tracks;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <div id="placeholder"></div>
            <div id="placeholder2"></div>
        </div>
        </form>
    </body>
    </html>
  • 相关阅读:
    Python-asyncio
    Python-异步编程
    软件工程个人作业01
    《构建之法》阅读笔记6
    《构建之法》阅读笔记5
    《构建之法》阅读笔记4
    《构建之法》阅读笔记3
    《构建之法》第二章阅读笔记
    《构建之法》第一章阅读笔记
    开发web信息管理系统用到的相关技术
  • 原文地址:https://www.cnblogs.com/hellolong/p/3990680.html
Copyright © 2020-2023  润新知