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 trial
Milan Epps
1,077 PointsAdapting Data for Display in a List: 2nd Code Challenge 1 of 3
I'm also having a bit of trouble on this challenge. Any suggestions?
Some YouTube data in the file 'data.json' has been loaded into a JSONObject named 'jsonData'. Using 'data.json' as your guide, write a 'for' loop that loops through 'jsonVideos'. In each step of the loop, store the value of the 'title' property in the 'titles' array.
for (i = 0; i < jsonVideos.length(); i ++) { JSONObject video = jsonVideos.getObject(i); String[] title = video.getString("title"); }
1 Answer
Arrington Copeland
23,505 PointsI think it should go something like this
JSONObject post = jsonVideos.getJSONObject(i); String title = post.getString("title"); titles[i] = title;
you can add the forloop yourself
Mark Josephsen
8,803 PointsMark Josephsen
8,803 PointsIt doesn't look like you're storing anything in an array named 'titles'. The last line in your for loop is creating a new array named 'title' instead of storing a value in an existing array named 'titles'. Instead, try something like this:
titles[i] = video.getString("title");