本文介绍了ASP JSON:对象不是一个集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该如何从这个JSON检索PitcherID?我使用的类。
JSON
[
{
PitcherID:456068
},
{
PitcherID:431148
}
]
code
oJSON.loadJSON(...)对于每一个东西在oJSON.data(PitcherID)
设置此= oJSON.data(PitcherID)。项目(事)
RESPONSE.WRITE this.item(PitcherID)
下一个
错误
Microsoft VBScript运行时错误'800a01c3对象不是一个集合
解决方案
问题是从
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:对象不是一个集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!