我已经从这个网站下载并设置了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")
但它会导致错误:"对象变量或With块变量未设置"。我希望得到" pve"值。我很困惑因为它以一个对象名称" realms"然后是一个数组。该数组应该作为集合返回。如果有任何帮助,我将不胜感激。
由于
答案 0 :(得分:3)
set objJSON = JSON.Parse(jsonFromUrl)
strData = objJSON.Item("realms").Item(1).Item("type")
json中的键区分大小写。