0

我正在尝试使用变量来表示该值来解析此 JSON,但它不起作用。我不知道是因为变量不代表字符串还是我不能做我想做的事情。

Function get_categoriesItems(category As Object) As Object

request = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
request.SetMessagePort(port)
request.SetUrl("http://jrocca.com/sample1.json")
if (request.AsyncGetToString())
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
playlist = CreateObject("roArray", 10, true)
print "";msg.GetString()
json = ParseJSON(msg.GetString())
print "";category
for each video in json.category
topic = {
Title: video.Title
Image: video.Image
Url: video.Url
}
playlist.push(topic)
print "";playlist
end for
return playlist
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
endif
return invalid

End Function

我能做些什么来解决这个问题?

4

1 回答 1

2

问题出在线路上for each video in json.category。将其替换为for each video in json.lookup(category)。这使用了roAssociativeArrayLookup(key as String) as Dynamic的功能。

于 2015-08-23T15:27:56.257 回答