title: Android - How to parse specific values from JSON Array and display Toast
body: <p>New to Android and Java in general and I'm learning how to make a JSON call. To do so, I'm following this guide: <a href="http://mobiforge.com/design-development/consuming-json-services-android-apps" rel="nofollow">http://mobiforge.com/design-development/consuming-json-services-android-apps</a></p>
  
  <p>Here's where things get confusing for me. The author of that tutorial wants the reader to call this API: <a href="http://ws.geonames.org/findNearByWeatherJSON?lat=37lng=122" rel="nofollow">http://ws.geonames.org/findNearByWeatherJSON?lat=37lng=122</a></p>
  
  <p>Which returns a JSON object in this format:</p>
  
  <pre><code>            {
                  "weatherObservation": {
                       "clouds":"scattered clouds",
                       "weatherCondition":"n/a",
                       "observation":"KCFV 090852Z AUTO 06005KT 
                        10SM SCT090 SCT110 24/20 A3000 RMK AO2 
                        SLP148 T02390200 53002",
                       "windDirection":60,
                       "ICAO":"KCFV",
                       "seaLevelPressure":1014.8,
                       "elevation":225,
                       "countryCode":"US",
                       "lng":-95.56666666666666,
                       "temperature":"23.9",
                       "dewPoint":"20",
                       "windSpeed":"05",
                       "humidity":78,
                       "stationName":"Coffeyville, Coffeyville 
                                   Municipal Airport",
                       "datetime":"2012-07-09 08:52:00",
                       "lat":37.083333333333336
                  }
              }
  </code></pre>
  
  <p>Pretty straight forward, except that the API is no longer valid/has limits. In order to finish the project I've instead opted to call this API: <a href="http://api.openweathermap.org/data/2.5/weather?lat=37.77&amp;lon=-122.419" rel="nofollow">http://api.openweathermap.org/data/2.5/weather?lat=37.77&amp;lon=-122.419</a></p>
  
  <p>Which returns the JSON in this format</p>
  
  <pre><code>{
      "coord": {
          "lon": 139,
          "lat": 35
      },
      "sys": {
          "country": "JP",
          "sunrise": 1369769524,
          "sunset": 1369821049
      },
      "weather": [
          {
              "id": 804,
              "main": "clouds",
              "description": "overcast clouds",
              "icon": "04n"
          }
      ],
      "main": {
          "temp": 289.5,
          "humidity": 89,
          "pressure": 1013,
          "temp_min": 287.04,
          "temp_max": 292.04
      },
      "wind": {
          "speed": 7.31,
          "deg": 187.002
      },
      "rain": {
          "3h": 0
      },
      "clouds": {
          "all": 92
      },
      "dt": 1369824698,
      "id": 1851632,
      "name": "Shuzenji",
      "cod": 200
  }
  </code></pre>
  
  <p>I can make the call just fine, but how do I display the "main" and "description" strings in the "weather" array? More specifically, how do I display this information as a Toast?</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>protected void onPostExecute(String result){
  
          try {
  
  
              JSONArray weatherArray = new JSONArray(result);
              JSONArray wArray = new JSONArray("weather");
  
              String mainWeather = wArray.getString(1);
              String mainDescription = wArray.getString(2);
  
              Toast.makeText(getBaseContext(), mainWeather + " - "
                          + mainDescription,Toast.LENGTH_SHORT).show();
  
          } catch (Exception e) {
              Log.d("ReadWeatherJSONFeedTask", e.getLocalizedMessage());
          }
  </code></pre>
  
  <p>BecauseI am following the mobiforge Tutorial, I have not deviated anywhere else except for this particular block of code.</p>
  
  <p>Thanks for the help!</p>
  
  <p><strong>Edit:</strong>
  There are several solutions here that work see @swats and @user3515851. I have chosen @remees-m-syde due to it's simplicity. Primarily because his solution did not require that I go through the for loop.  </p>