Iterating though a JSON return using ASP Xtreme Evolution

别等时光非礼了梦想. 提交于 2019-12-12 05:15:37

问题


I'm trying to parse a return from Twitter using classic ASP with ASP Xtreme Evolution JSON Parser https://github.com/nagaozen/asp-xtreme-evolution/blob/master/lib/axe/classes/Parsers/json2.asp

To keep things simple, here's a trimmed JSON return:

[{
    "user": {
    "id": 19720970
    }
}, {
    "user": {
    "id": 201195798
    }
}, {
    "user": {
    "id": 19768935
    }
}]

What I need to do is iterate through each user to discover the id. The best I've got so far only returns the last id:

dim Info : set Info = JSON.parse(join(array(jsonResponse)))
dim key : For Each key in Info.user.keys()
    Response.Write Info.user.id & "<br>" 'only 19768935 is printed
Next
set Info = nothing

Does anyone have any ideas how to retireve each id?

A second query (but less urgent) is that I can only get this to parse if I remove the outlying square brackets. Why is this and is there a way to parse it with them in?

Many thanks Justin


回答1:


Thanks to all those who have taken a look at this problem.

After trying a number of things including reformatting the response on the fly, I've found the rather simple answer to my problem:

For Each key in Info.keys()
    Response.Write Info.get(key).user.id & "<br />"
Next

Hope that helps anyone in the future :-)



来源:https://stackoverflow.com/questions/14257055/iterating-though-a-json-return-using-asp-xtreme-evolution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!