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.

Max OSX Mavericks
Xojo 4.1
  Dim socket As New HTTPSocket
  Dim url As String = "*"
  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"))

Which should result in: