文章詳情頁
ASP 處理JSON數(shù)據(jù)的實現(xiàn)代碼
瀏覽:191日期:2022-06-05 08:36:22
ASP也能處理JSON數(shù)據(jù)?呵呵,剛才在Pjblog論壇上看到一個兄弟寫的文章,沒有測試,不過理論上一定是可以的~ 太晚了,不測試了。
以前處理JSON太麻煩了,輸出還好說,循環(huán)一下就可以了,解析真的很頭疼。所以遇到 這種問題API問題,一般都是XML處理,不太喜歡,很麻煩。
<% Dim sc4Json Sub InitScriptControl Set sc4Json = Server.CreateObject("MSScriptControl.ScriptControl") sc4Json.Language = "JavaScript" sc4Json.AddCode "var itemTemp=null;function getJSArray(arr, index){itemTemp=arr[index];}" End Sub Function getJSONObject(strJSON) sc4Json.AddCode "var jsonObject = " & strJSON Set getJSONObject = sc4Json.CodeObject.jsonObject End Function Sub getJSArrayItem(objDest,objJSArray,index) On Error Resume Next sc4Json.Run "getJSArray",objJSArray, index Set objDest = sc4Json.CodeObject.itemTemp If Err.number=0 Then Exit Sub objDest = sc4Json.CodeObject.itemTemp End Sub Dim strTest strTest = "{name:""alonely"", age:24, email:[""ycplxl1314@163.com"",""ycplxl1314@gmail.com""], family:{parents:[""父親"",""母親""],toString:function(){return ""家庭成員"";}}}" Dim objTest Call InitScriptControl Set objTest = getJSONObject(strTest) %> <%=objTest.name%>的郵件地址是< %=sc4Json.Eval("jsonObject.email[0]")%><br />共有郵件地址< %=objTest.email.length%>個<br /> <% Dim father getJSArrayItem father, objTest.family.parents, 0 Response.Write father %>
更多相關(guān)ASP 處理JSON的文章可以繼續(xù)往下看
標(biāo)簽:
ASP
相關(guān)文章:
1. ajax請求后臺得到j(luò)son數(shù)據(jù)后動態(tài)生成樹形下拉框的方法2. asp批量添加修改刪除操作示例代碼3. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對象Application和Session)4. AspNetCore&MassTransit Courier實現(xiàn)分布式事務(wù)的詳細(xì)過程5. ASP中解決“對象關(guān)閉時,不允許操作。”的詭異問題……6. ASP基礎(chǔ)知識Command對象講解7. ASP腳本組件實現(xiàn)服務(wù)器重啟8. ASP基礎(chǔ)入門第三篇(ASP腳本基礎(chǔ))9. ASP.NET泛型三之使用協(xié)變和逆變實現(xiàn)類型轉(zhuǎn)換10. ASP中if語句、select 、while循環(huán)的使用方法
排行榜
