宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

[AS3]ASP处理解析JSON数据格式的示例

2016-10-13 00:16:48 点击量:24 标签: 收藏本文

[AS3]ASP处理解析JSON数据格式的示例

  1. <%    
  2. Dim sc4Json     
  3. Sub InitScriptControl    
  4. Set sc4Json = Server.CreateObject("MSScriptControl.ScriptControl")    
  5.     sc4Json.Language = "JavaScript"    
  6.     sc4Json.AddCode "var itemTemp=null;function getJSArray(arr, index){itemTemp=arr[index];}"    
  7. End Sub     
  8. Function getJSONObject(strJSON)    
  9.     sc4Json.AddCode "var jsonObject = " & strJSON    
  10.     Set getJSONObject = sc4Json.CodeObject.jsonObject    
  11. End Function     
  12. Sub getJSArrayItem(objDest,objJSArray,index)    
  13.     On Error Resume Next    
  14.     sc4Json.Run "getJSArray",objJSArray, index    
  15.     Set objDest = sc4Json.CodeObject.itemTemp    
  16.     If Err.number=0 Then Exit Sub    
  17.     objDest = sc4Json.CodeObject.itemTemp    
  18. End Sub    
  19. Dim strTest    
  20. strTest = "{name:""alonely"", age:24, email:[""ycplxl1314@163.com"",""ycplxl1314@gmail.com""], family:{parents:[""父亲"",""母亲""],toString:function(){return ""家庭成员"";}}}"    
  21. Dim objTest    
  22. Call InitScriptControl    
  23. Set objTest = getJSONObject(strTest)    
  24. %>    
  25. <%=objTest.name%>的邮件地址是<%=sc4Json.Eval("jsonObject.email[0]")%><BR>共有邮件地址<%=objTest.email.length%><BR>    
  26. <%    
  27. Dim father    
  28. getJSArrayItem father, objTest.family.parents, 0    
  29. Response.Write father    
  30. %>    

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室