Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free triallaze dimitrovski
1,535 PointsgetDailyForecast() and getHourlyForecast() don't return anything.
Here is my code, the code is the same for the getDailyForecast() method.
private Hour[] getHourlyForecast(String jsonData) throws JSONException {
JSONObject forecast = new JSONObject(jsonData);
String timezone = forecast.getString("timezone");
JSONObject hourly = forecast.getJSONObject("hourly");
JSONArray data = hourly.getJSONArray("data");
Log.v("HORSEDATA", data.toString());
Hour[] hours = new Hour[data.length()];
for(int i = 0 ; i < i; i++){
JSONObject jsonHour = data.getJSONObject(i);
Hour hour = new Hour();
hour.setSummary(jsonHour.getString("summary"));
hour.setTemp(jsonHour.getDouble("temperature"));
hour.setIcon(jsonHour.getString("icon"));
hour.setTime(jsonHour.getLong("time"));
hour.setTimezone(timezone);
hour.setPrecip(jsonHour.getDouble("precipProbability"));
hours[i] = hour;
}
return hours;
}
Tried calling the through Forecast.class and without it, same result.
Joe Brown
21,465 PointsJoe Brown
21,465 PointsWas that a typing error in your for loop? You have while i < i instead of i < data.length()