I know a similar question has been asked and answered before a few times:
Parsing JSON in Excel VBA,
Excel VBA: Parsed JSON Object Loop
However, the above solution doesn't work if I am trying to access an array within the returned object. I'm receiving a JSON object from the Google Translate API in the following format:
"{
"sentences":[
{
"trans":"Responsibility
",
"orig":"??",
"translit":"",
"src_translit":"Zérèn"
},
{
"trans":"Department",
"orig":"??",
"translit":"",
"src_translit":"Bùmén"
}
],
"src":"zh-CN",
"server_time":86
}"
I want to be able to access the two translated sentences as sentences(0) and sentences(1). I can use the GetProperty() method from the previous posts to retrieve the sentences object, but I can't access its members because it is an object of type JScriptTypeInfo, not an array.
I've tried to convert the sentences object to an array in JScript using something similar to the method described here: How to pass arrays between javaScript and VBA. I can only get it to return the first value of the array, for some reason.
What would be the best way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…