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 trialMichael Ikhane
2,390 PointsChallenge 2 of 3
I get this error even though i have done everything correctly.
ERROR:
Bummer! Compilation Error! Make sure you are calling 'getJSONArray()' from the 'jsonData' variable and storing the result in a JSONArray variable!
CODE:
String name = jsonData.getString("name") ;
String publisher = jsonData.getString("publisher") ;
String language = jsonData.getString("language") ;
JSONArray jsonBooks = jsonData.getJSONArray("books");
for (int index = 0 ; index < jsonBooks.length() ; index++ ) {
JSONObject jsonBook = jsonBooks.getJSONObject(index);
String title = jsonBook.getString("title") ;
String pages = jsonBook.getString("pages") ;
Log.i("CodeChallenge" ; title + ", " + pages );
}
2 Answers
Jose Andrade-Sinning
Python Web Development Techdegree Student 12,676 PointsMichael,
I believe the problem in your code is on the last line because you are using the wrong delimeter to mark the parameter:
Log.i("CodeChallenge" ; title + ", " + pages );
it should be instead:
Log.i("CodeChallenge", title + ", " + pages );
Michael Ikhane
2,390 PointsPlease pardon my delayed gratitude. Thanks Jose