首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

解析json数组,该怎么解决

2012-02-03 
解析json数组Sub figjson3()ok可以解析json数组 ,请教高手怎么解析数组嵌套数组.Dim aaaa {myname

解析json数组
Sub figjson3() 'ok 可以解析json数组 ,请教高手怎么解析数组嵌套数组.
Dim aa
aa = "{""myname"":""Michael"",""myaddress"":{""city"":""Beijing"",""street"":"" Chaoyang Road "",""postcode"":100025}}"
   
  Set X = CreateObject("ScriptControl")
  X.Language = "JScript"
   
  s = "function j(s) { return eval('(' + s + ')'); }"
  X.AddCode s
  Set y = X.Run("j", aa)
   
  MsgBox y.myname
  MsgBox y.myaddress
MsgBox y.myaddress.city
MsgBox y.myaddress.postcode
End Sub


例子  
Sub jsontest() 'error
Dim aa
aa = "{ ""people"": [{ ""firstName"": [{'code':'40001','name':'累计折旧/固定资产原值'},{'code':'40005','name':'累值'}], ""lastName"":""McLaughlin"", ""email"": ""brett@newInstance.com"" },{ ""firstName"": 123, ""lastName"":""Hunter"", ""email"": ""jason@servlets.com"" }, { ""firstName"": ""Elliotte"", ""lastName"":""Harold"", ""email"": ""elharo@macfaq.com"" }]}"
  Set X = CreateObject("ScriptControl")
  X.Language = "JScript"
  i = 0
  s = "function j(s) { return eval('(' + s + ').people[ " & i & "]'); }"
  X.AddCode s
  Set y = X.Run("j", aa)

  Debug.Print y.firstName.code
  Debug.Print y.firstName, y.lastName
End Sub

[解决办法]
http://www.ediy.co.nz/vbjson-json-parser-library-in-vb6-xidc55680.html
去这里下载json解析器吧
[解决办法]
不会啊,能下载,你这是什么网啊,墙这么厉害?
http://www.ediy.co.nz/content.asp?syscmd=dl&ID=A06786CB3E7E4F878FA542DBEE4B60B5

热点排行