求ASP解析JSON打印所有的目录和节点和值-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

求ASP解析JSON打印所有的目录和节点和值

2016-07-05 08:56:42 2557 1

水平太差,使用ASP自带的解析涵数后不知道如何输出里面的节点和内容信息

 function ToObject(json) {    var o;    eval("o=" + json);    return o;}set obj1 = ToObject(teststr)Response.Write obj1.title & "<br />"本人到这就卡住了
上面代码是用来解析的,但是我只能打印出第一个title=“最攒劲乡镇街道”的值,后面的就不知道怎么操作了,求高手指教,附带JSON数据
{"title":"最攒劲乡镇街道","vote_permission":2,"expire_time":1430406000,"total_person":12889,"vote_subject":[{"type":1,"title":"戳出你心中最攒劲的乡镇!","options":[{"name":"物流重镇三工","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIyKZ5GCL8sZFg8yVQDK4ZkCQ6BDBF2Zh9M3VADI5MYRXkFqTjOFS8Uw\/0?wx_fmt=jpeg","cnt":855,"selected":false},{"name":"区镇合一榆树沟","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIM6O7nuD77BRwcYxCnZlFvpClNnVNib9C7UUe1P29SAichGSknHb565BA\/0?wx_fmt=jpeg","cnt":2010,"selected":false},{"name":"宜居创业之镇大西渠","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIACoqqFrafyGA6G8lbvJ1UfqLB8dylmLk9mZxfqpKw3LuDm4NLx0guw\/0?wx_fmt=jpeg","cnt":2309,"selected":false},{"name":"矿业重镇硫磺沟","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIxeV6Z0zXyncCEWlzPQHIkrhurC4AajjHd4H2liaYVtDwoia5Wc0YLBgQ\/0?wx_fmt=jpeg","cnt":1397,"selected":false},{"name":"渔米之乡六工","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIvHdrZ9r8sq6c2XHUtvovD4F4w6EmGuObNY4Mo97uHDWg5cde6icZMiag\/0?wx_fmt=jpeg","cnt":743,"selected":false},{"name":"“花儿之乡”二六工镇","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIYBq22k40P8YJNkFIgOWJE2HOse1ee184F0icnjkEHJpEhL9LNTsuJTA\/0?wx_fmt=jpeg","cnt":715,"selected":false},{"name":"生态宜居滨湖镇","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIISxHWjb8kNsic6SS5TOicrmDJBSf3gUtyFElxM42ynFW1JL3LcT0K8ctg\/0?wx_fmt=jpeg","cnt":2175,"selected":false},{"name":"特色风情阿什里","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIQ2K0UII39wjSJAA1KJjziccHkjakOUyFJQKRlAYm7tnoQXYVFrq0ibEg\/0?wx_fmt=jpeg","cnt":782,"selected":false},{"name":"定居样板庙尔沟","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYII3zG9RETg4pfD3sqGsFRGliczib0swxwjibDU9micd5lXPQnM4YPU3Fd2cQ\/0?wx_fmt=jpeg","cnt":793,"selected":false},{"name":"生态农业旅游强镇佃坝","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIZMwJ4TBIYNKPZicTQKGp4EthF44g0lTVpv7GeapavgnrI8qpQPl8ZYw\/0?wx_fmt=jpeg","cnt":1110,"selected":false}],"total_cnt":12889,"vote_id":617881},{"type":1,"title":"戳出你心中最攒劲街道!","options":[{"name":"延安北路街道","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIRxYQReiaFJuVNBzicbXG5Ty6gvzI4gVN9T3O5GnB71ynpZic1GNMr4tww\/0?wx_fmt=jpeg","cnt":2627,"selected":false},{"name":"北京南路街道","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIC2QUpZvQFh8v3nxkDwxbQstKZsGDS3LEqqWAecdvHpHQDWm6Ie1Haw\/0?wx_fmt=jpeg","cnt":2185,"selected":false},{"name":"宁边路街道","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIEOYNDk7Sp4V8xgiaou5CdeBURyXAHS0dIzcff6Fd9Mr9J1I65l5jOgg\/0?wx_fmt=jpeg","cnt":1772,"selected":false},{"name":"绿洲路街道","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIcnKSaYhacAdmd72Sia3y6dB15SDCzvAYfEy1vFt8H38Jc2a9xzBPZBg\/0?wx_fmt=jpeg","cnt":1819,"selected":false},{"name":"中山路街道","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIbGibWJic5Du2cy5icGa8mUcuOD2lTSBAXOmtZr9ic3oUqn6zCsS5kPduEQ\/0?wx_fmt=jpeg","cnt":2264,"selected":false},{"name":"建国路街道","url":"http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIjEYfw0p0vGqBWEuq49pQcyeB8bv2IxlOBPvoicJ5mlsOKvs1MHg8x1g\/0?wx_fmt=jpeg","cnt":2221,"selected":false}],"total_cnt":12888,"vote_id":617882}],"super_vote_id":412550,"del_flag":0}
取消 提交回答
全部回答(1)
  • 杨冬芳
    2019-07-17 19:51:08

    解析全部用jscript,不用用vbscript,你用jscript eval出来的json对象包含json数组vbscript不知道怎么解析。。。

    要么你就下载这个类,用下面的代码进行解析:asp json类库

     <!--#include file="aspJSON1.17.asp"-->
    <%
    teststr = "{""title"":""最攒劲乡镇街道"",""vote_permission"":2,""expire_time"":1430406000,""total_person"":12889,""vote_subject"":[{""type"":1,""title"":""戳出你心中最攒劲的乡镇!"",""options"":[{""name"":""物流重镇三工"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIyKZ5GCL8sZFg8yVQDK4ZkCQ6BDBF2Zh9M3VADI5MYRXkFqTjOFS8Uw\/0?wx_fmt=jpeg"",""cnt"":855,""selected"":false},{""name"":""区镇合一榆树沟"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIM6O7nuD77BRwcYxCnZlFvpClNnVNib9C7UUe1P29SAichGSknHb565BA\/0?wx_fmt=jpeg"",""cnt"":2010,""selected"":false},{""name"":""宜居创业之镇大西渠"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIACoqqFrafyGA6G8lbvJ1UfqLB8dylmLk9mZxfqpKw3LuDm4NLx0guw\/0?wx_fmt=jpeg"",""cnt"":2309,""selected"":false},{""name"":""矿业重镇硫磺沟"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIxeV6Z0zXyncCEWlzPQHIkrhurC4AajjHd4H2liaYVtDwoia5Wc0YLBgQ\/0?wx_fmt=jpeg"",""cnt"":1397,""selected"":false},{""name"":""渔米之乡六工"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIvHdrZ9r8sq6c2XHUtvovD4F4w6EmGuObNY4Mo97uHDWg5cde6icZMiag\/0?wx_fmt=jpeg"",""cnt"":743,""selected"":false},{""name"":""“花儿之乡”二六工镇"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIYBq22k40P8YJNkFIgOWJE2HOse1ee184F0icnjkEHJpEhL9LNTsuJTA\/0?wx_fmt=jpeg"",""cnt"":715,""selected"":false},{""name"":""生态宜居滨湖镇"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIISxHWjb8kNsic6SS5TOicrmDJBSf3gUtyFElxM42ynFW1JL3LcT0K8ctg\/0?wx_fmt=jpeg"",""cnt"":2175,""selected"":false},{""name"":""特色风情阿什里"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIQ2K0UII39wjSJAA1KJjziccHkjakOUyFJQKRlAYm7tnoQXYVFrq0ibEg\/0?wx_fmt=jpeg"",""cnt"":782,""selected"":false},{""name"":""定居样板庙尔沟"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYII3zG9RETg4pfD3sqGsFRGliczib0swxwjibDU9micd5lXPQnM4YPU3Fd2cQ\/0?wx_fmt=jpeg"",""cnt"":793,""selected"":false},{""name"":""生态农业旅游强镇佃坝"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIZMwJ4TBIYNKPZicTQKGp4EthF44g0lTVpv7GeapavgnrI8qpQPl8ZYw\/0?wx_fmt=jpeg"",""cnt"":1110,""selected"":false}],""total_cnt"":12889,""vote_id"":617881},{""type"":1,""title"":""戳出你心中最攒劲街道!"",""options"":[{""name"":""延安北路街道"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIRxYQReiaFJuVNBzicbXG5Ty6gvzI4gVN9T3O5GnB71ynpZic1GNMr4tww\/0?wx_fmt=jpeg"",""cnt"":2627,""selected"":false},{""name"":""北京南路街道"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIC2QUpZvQFh8v3nxkDwxbQstKZsGDS3LEqqWAecdvHpHQDWm6Ie1Haw\/0?wx_fmt=jpeg"",""cnt"":2185,""selected"":false},{""name"":""宁边路街道"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIEOYNDk7Sp4V8xgiaou5CdeBURyXAHS0dIzcff6Fd9Mr9J1I65l5jOgg\/0?wx_fmt=jpeg"",""cnt"":1772,""selected"":false},{""name"":""绿洲路街道"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIcnKSaYhacAdmd72Sia3y6dB15SDCzvAYfEy1vFt8H38Jc2a9xzBPZBg\/0?wx_fmt=jpeg"",""cnt"":1819,""selected"":false},{""name"":""中山路街道"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIbGibWJic5Du2cy5icGa8mUcuOD2lTSBAXOmtZr9ic3oUqn6zCsS5kPduEQ\/0?wx_fmt=jpeg"",""cnt"":2264,""selected"":false},{""name"":""建国路街道"",""url"":""http:\/\/mmbiz.qpic.cn\/mmbiz\/Y2eca8dznyzbU5cV9f5F5QPYficVYicYIIjEYfw0p0vGqBWEuq49pQcyeB8bv2IxlOBPvoicJ5mlsOKvs1MHg8x1g\/0?wx_fmt=jpeg"",""cnt"":2221,""selected"":false}],""total_cnt"":12888,""vote_id"":617882}],""super_vote_id"":412550,""del_flag"":0}"
    
    set o=new aspJSON
    o.loadjson(teststr)
    response.Write o.data("title")&"<br/>"
    ''''此节点其他属性
    for each vote_subject in o.data("vote_subject")
      set item=o.data("vote_subject")(vote_subject)
      response.Write item.item("type")&"<br>"
      response.Write item.item("title")&"<br>"
      '此节点下其他属性
      for each options in item.item("options")
        set itemop=item.item("options")(options)
        response.Write itemop.item("name")&"<br>"
        response.Write itemop.item("url")&"<br>"
      '此节点下其他属性
      next
    next
    
    set o=nothing
     %>
    
    0 0
相关问答

1

回答

asp.net的语言特点是什么?

2021-10-20 00:13:05 254浏览量 回答数 1

1

回答

asp.net是什么?

2021-10-20 00:07:16 216浏览量 回答数 1

1

回答

ASP.NET网站换到自己的电脑上打不开了?报错

2020-06-20 19:12:59 244浏览量 回答数 1

1

回答

ASP.NET程序网站如何在多个站点之间实现session共享?

2019-07-12 09:31:05 351浏览量 回答数 1

1

回答

ASP.NET中找不到文件是什么意思呢?

2016-06-07 14:48:06 1523浏览量 回答数 1

1

回答

问一个c# asp.net 的问题

2016-03-23 13:35:19 1308浏览量 回答数 1

1

回答

独享高级版怎么不支持ASP.NET

2015-12-13 19:30:27 2762浏览量 回答数 1

1

回答

上传asp.net访问出错,急求解决方法!

2015-04-24 21:45:27 3621浏览量 回答数 1

7

回答

咨询asp.net的站能搬到阿里云吗

2012-09-27 16:27:39 10925浏览量 回答数 7

1

回答

新购1核1G+1M=800元3年,老用户不服啊!专坑老用户!!!!

2017-06-24 14:51:17 2274浏览量 回答数 1
+关注
杨冬芳
IT从业
1
文章
9167
问答
问答排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载