|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 sinitek123 于 2012-12-10 17:29 编辑
最近开发遇到了解析json数组问题,参考http://club.excelhome.net/forum.php?mod=viewthread&tid=483942&page=1#pid3170407可以解决数组.
可是我的需要的是数组里面又有数组,请求高手帮忙.
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.lastName
End Sub
people firstname 下面是数组的话,怎么取下面的值.
副档有成功和失败的例子.
json数组.zip
(10.49 KB, 下载次数: 217)
|
|