How to access the follow JSON?

I have this...

{visibility=>10000, main=>{temp=>16.870001, humidity=>88, temp_min=>16.670000, temp_max=>17, pressure=>1022}, weather=>[{main=>Rain, id=>500, description=>light rain, icon=>10n}], coord=>{lat=>50.830002, lon=>-0.140000}, cod=>200, dt=>1439327967, sys=>{sunset=>1439321264, message=>0.012800, type=>1, sunrise=>1439268153, id=>5089, country=>GB}, base=>stations, wind=>{deg=>30, speed=>2.600000}, clouds=>{all=>92}, id=>2654710, name=>Brighton}

And can access for example the temp like this

w.temperature = data["main"]["temp"];

But how can I access the weather/description as this doesn't work

w.weather = data["weather"]["description"];

TIA!
  • Any idea how to map the icon code that comes back to pictures that represent the weather?
  • You can fetch the icon from their site, or you can map the weather condition code (or icon name) to resources you've built into your application. Assuming you build the icon into the application, the following would probably work.

    class WeatherView extends Ui.View
    {
    hidden var _map;

    function initialize() {

    _map = {
    "01d" => Rez.Bitmaps.01d,
    "02d" => Rez.Bitmaps.02d,
    "03d" => Rez.Bitmaps.03d,
    "04d" => Rez.Bitmaps.04d,
    "09d" => Rez.Bitmaps.09d,
    "10d" => Rez.Bitmaps.10d,
    "11d" => Rez.Bitmaps.11d,
    "13d" => Rez.Bitmaps.13d,
    "50d" => Rez.Bitmaps.50d,
    "01n" => Rez.Bitmaps.01n,
    "02n" => Rez.Bitmaps.02n,
    "03n" => Rez.Bitmaps.03n,
    "04n" => Rez.Bitmaps.04n,
    "09n" => Rez.Bitmaps.09n,
    "10n" => Rez.Bitmaps.10n,
    "11n" => Rez.Bitmaps.11n,
    "13n" => Rez.Bitmaps.13n,
    "50n" => Rez.Bitmaps.50n
    }
    }

    function onResponse(code, data) {
    if (data != null) {
    // assuming you use layouts
    var drawable = findDrawableById("Icon");

    var name = data["weather"][0]["icon"];
    drawable.setBitmap(_map[name]);
    }
    }
    }