您可以使用ScriptControl对象创建一个可以运行javascript的环境.如果您习惯在网页中使用JSON,那么这可能是一种简单的方法.

例:

Sub Tester()

Dim json As String

Dim sc As Object

Dim o

Set sc = CreateObject("scriptcontrol")

sc.Language = "JScript"

json = {get your json here}

sc.Eval "var obj=(" & json & ")" 'evaluate the json response

'add some accessor functions

sc.AddCode "function getSentenceCount(){return obj.sentences.length;}"

sc.AddCode "function getSentence(i){return obj.sentences[i];}"

Debug.Print sc.Run("getSentenceCount")

Set o = sc.Run("getSentence", 0)

Debug.Print o.trans, o.orig

End Sub

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐