O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a JSON web service

In this recipe, we make a browser app ask data from a web service (Yahoo stock data) in JSON format, decode that data, and dynamically build up the web page showing the data.

Getting ready

This is what the URL we will use will look like: http://query.yahooapis.com/v1/public/yql?q=SELECT.

To get the data, we use the Yahoo Query Language (YQL), q= indicating the start of the query represented by SELECT. Suppose we want to look up stock data for Yahoo, Google, Apple, and Microsoft, the selected query will be of the following form:

select * from yahoo.finance.quotes where symbol in(YHOO,AAPL,GOOG,CMSFT) &env=http://datatables.org/Falltables.env&format=json

How to do it...

Look at the code in stockviewer_dart:

import 'dart:html'; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required