O'Reilly logo

Reactive Android Programming by Tadas Subonis

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

Parsing JSON

First of all, we will start with JSON parsing. Most of that will be handled by the Gson library. However, we still need to correctly create a tree class that will be used to contain it.

Yahoo API returns a structure that should resemble something like this:

{  "query": {    "count": 4,    "created": "2000-00-00T00:00:45Z",    "lang": "en-US",    "results": {      "quote": [        {          "symbol": "YHOO",          "AverageDailyVolume": "10089100",          "Change": "+0.86",          "DaysLow": "41.00",          "DaysHigh": "42.00",          "YearLow": "26.15",          "YearHigh": "44.00",          "MarketCapitalization": "40.00B",          "LastTradePriceOnly": "42.00",          "DaysRange": "41.54 - 42.37",          "Name": "Yahoo! Inc.",          "Symbol": "YHOO",          "Volume": "4645383",          "StockExchange": "NMS"        },        ...      ]    }  }}

Different levels of nesting ...

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