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 trialBen Mair
8,728 PointsjsonArray JsonShow
having different errors mainly pertaining to the value of i variable.......any thoughts?
JSONArray jsonShows = jsonData.getJSONArray("Shows");
for (int i=0; i<jsonShows.length(); i++); {
JSONObject showsObject = jsonShows.getJSONObject(i);
Log.i("CodeChallenge", showsObject.getString("title"));
}
{
"name":"Netflix Playlist",
"shows":[
{
"title":"Doctor Who",
"season":8,
"episode":3
},
{
"title":"Arrow",
"season":1,
"episode":10
},
{
"title":"Portlandia",
"season":4,
"episode":5
}
]
}
Stephen Little
8,312 PointsTry changing your "Shows" to just lower s "shows"
JSONArray jsonShows = jsonData.getJSONArray("Shows");
to
JSONArray jsonShows = jsonData.getJSONArray("shows");
That is what I believe the JSONArray name value is...
Cheers! Stephen
Stephen Little
8,312 PointsOk my code does not have any compiler errors so I must be logging wrong somehow. Should I put the "title" into a var before using in the Log call? Not sure if that would make any difference or not,
1 Answer
Stephen Little
8,312 PointsI think what will solve your problem is just the letter "S" to a small "s" in your array call. I found my problem, I had the number 1 in my for loop instead or the "i" like it should of been (DOH!).... I hope your code work once you get that crazy "S" under control, silly "S" stop being on difficult :)
Cheers! Stephen
Stephen Little
8,312 PointsStephen Little
8,312 PointsI am having the same problem and I don't think our code looks really different.... did you find out what was wrong?