受苦的同胞们!
请看我的代码。此时,我有一个名为objJSON的对象。正如你所看到的,它包含了很好的信息。但请帮助我获得位置1/项目1/authorDisplayname的信息,它将是字符串"Jens Christian“。
提前感谢
彼得·B·汉森
发布于 2017-05-17 04:03:21
这里有一种方法:
Dim oScriptEngine As ScriptControl
Set oScriptEngine = New ScriptControl
oScriptEngine.Language = "JScript"
'create a js object in the scriptengine
'(loading a sample of your json from a worksheet cell)
oScriptEngine.Eval ("var json=(" + Range("A3").Value + ")")
'query the object properties
Debug.Print oScriptEngine.Eval("json.length") '>> 3
Debug.Print oScriptEngine.Eval("json[0].authorDisplayName") '>> Peter Bunde Hansen但是,如果您要执行此操作,则应考虑使用诸如https://github.com/VBA-tools/VBA-JSON之类的工具
https://stackoverflow.com/questions/43984934
复制相似问题