Get stock quotes with JSON from Yahoo in Xojo

A source code example how to use Xojo to get a list of stock quotes from the yahoo finance website using HTTPSocket and JSONItem to read and filter through the json response data.

Using:
Max OSX Mavericks
Xojo 4.1



Dim socket As New HTTPSocket

Dim url As String =

"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22YHOO%22%2C%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json"

Dim jsonData As String = socket.Get(url,30)
Dim apiResponse as new JSONItem(jsonData)

dim filteredByQuery as JSONItem = apiResponse.child("query")
dim filteredByResults as JSONItem = filteredByQuery.Value("results")
dim filteredByQuote as JSONItem = filteredByResults.Value("quote")

dim n as JSONItem
dim quotes() as string
dim i as integer

for i = 0 to filteredByQuote.Count - 1
    n= filteredByQuote.child(i)
    MsgBox(n.value("symbol")+" "+n.value("LastTradePriceOnly"))
 next


Which should result in:

Taxonomy