0

我已经从这个网站下载并设置了 VB6 的 JSON 解析器: VB-JSON

我无法理解这个模块是如何工作的。我在 Excel 2010 中成功设置了它,我想我也理解 JSON 格式,但我不知道这个类如何提取项目。我尝试以 JSON 格式解析以下文本

{"realms":[{"type":"pvp","population":"low","queue":false,"wintergrasp":{"area":1,"controlling-faction":1,"status":0,"next":1356724174636},"tol-barad":{"area":21,"controlling-faction":1,"status":0,"next":1356723246779},"status":true,"name":"Kor'gall","slug":"korgall","battlegroup":"Cruelty / Crueldad","locale":"en_GB","timezone":"Europe/Paris"},{"type":"pve","population":"medium","queue":false,"wintergrasp":{"area":1,"controlling-faction":0,"status":0,"next":1356724425638},"tol-barad":{"area":21,"controlling-faction":0,"status":0,"next":1356723369780},"status":true,"name":"Alonsus","slug":"alonsus","battlegroup":"Cruelty / Crueldad","locale":"en_GB","timezone":"Europe/Paris"}]}

当使用以下地址时,浏览器将返回此内容: Alonsus, Kor'gall

我写了一个类似的代码

Dim objJSON As Object
...
strData = objJSON.Item("Realms")(1).Item("Type")

但它会导致错误:“对象变量或未设置块变量”。我希望得到“pve”值。我很困惑,因为它以对象名称“领域”开头,后跟一个数组。该数组应该作为集合返回。我将不胜感激。

谢谢

4

1 回答 1

3
set objJSON = JSON.Parse(jsonFromUrl)
strData = objJSON.Item("realms").Item(1).Item("type")

json 中的键是区分大小写的。

于 2012-12-28T18:45:19.370 回答