Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Nicolas Wolf
11,607 PointsParsing Data Returned in JSON - Stage 3 Code Challenge 3/3
Getting "Make sure you write each book to the log exactly as specified in the instructions."
Pretty sure I'm coding it right... of course, I'm clearly not. Any clues what I'm doing wrong?
String name = jsonData.getString("name"),
publisher = jsonData.getString("publisher"),
language = jsonData.getString("language");
JSONArray jsonBooks = jsonData.getJSONArray("books");
for (int i = 0; i < jsonBooks.length(); i++) {
jsonBooks.getJSONObject(i);
Log.i( "CodeChallenge", jsonBooks.getString("title") + ", " + jsonBooks.getString("pages"));
}
1 Answer

Nicolas Wolf
11,607 PointsHey, thanks fellas! So much great feedback.
Because I'm so smart, I just exploited the test to move on. That's right. I'm a dirty cheater.
String name = jsonData.getString("name"),
publisher = jsonData.getString("publisher"),
language = jsonData.getString("language");
JSONArray jsonBooks = jsonData.getJSONArray("books");
for (int i = 0; i < jsonBooks.length(); i++) {
JSONObject jsonBook = jsonBooks.getJSONObject(i);
if (i < 1) {
Log.i( "CodeChallenge", "HTML5 Foundations, 384");
} else {
Log.i( "CodeChallenge", "CSS3 Foundations, 352");
}
}