ASP JSON:对象不是一个集合 [英] ASP JSON: Object not a collection
问题描述
我应该如何从这个JSON检索PitcherID?我使用的 http://aspjson.com 类。
JSON
[
{
PitcherID:456068
},
{
PitcherID:431148
}
]
code
oJSON.loadJSON(...)对于每一个东西在oJSON.data(PitcherID)
设置此= oJSON.data(PitcherID)。项目(事)
RESPONSE.WRITE this.item(PitcherID)
下一个
错误
Microsoft VBScript运行时错误'800a01c3对象不是一个集合
问题是从 http://aspjson.com <类/ A>是有限的,我个人一直觉得很难找到如何使用它体面的例子。
为什么你获得对象不是一个集合
错误?
这很简单真的是你试图像数组遍历对象/集合是一个也没有。
这行
对于每一个东西在oJSON.data(PitcherID)
将失败,因为 oJSON.data(PitcherID)
不是一个集合对象,这意味着你无法通过它进行迭代。对于 PitcherID
是枚举源JSON结构看起来会像这样
{
PitcherID:[
456068,
431148
]
}
例如
链接
How should I retrieve PitcherID from this JSON? I am using the class from http://aspjson.com.
JSON
[
{
"PitcherID": "456068"
},
{
"PitcherID": "431148"
}
]
Code
oJSON.loadJSON("...")
For Each thing In oJSON.data("PitcherID")
Set this = oJSON.data("PitcherID").item(thing)
response.write this.item("PitcherID")
Next
Error
Microsoft VBScript runtime error '800a01c3'
Object not a collection
The problem is the class from http://aspjson.com is limited and personally I've always found it hard to find decent examples of how to use it.
Why do you get the Object not a collection
error?
It's quite simple really the object you are trying to iterate through like an array / collection is not one.
This line
For Each thing In oJSON.data("PitcherID")
will fail because oJSON.data("PitcherID")
is not a collection object which means you cannot iterate through it. For PitcherID
to be enumerable the source JSON structure would look more like this
{
"PitcherID": [
"456068",
"431148"
]
}
for example.
Links
这篇关于ASP JSON:对象不是一个集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!