首页 > 代码库 > JOSN反串行化
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>
JOSN反串行化
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。