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.

Android

Mike Costa
PLUS
Mike Costa
Courses Plus Student 26,361 Points

Parsing Data Returned in JSON Format Challenge issue?

I'm trying to complete to last code challenge in the android, Build a Blog Reader, project, however, I am getting the error "Make sure you write each book to the log exactly as specified in the instructions." The instructions read:

"Then use the 'Log.i()' method (with "CodeChallenge" as the tag) to write the book title, a comma, a space, and the number of pages. Ex. output: 'Book title 1, 300'."

for(int i = 0; i < jsonBooks.length(); i++){
    JSONObject jsonBook = jsonBooks.getJSONObject(i);
    String title = jsonBook.getString("title");
    String pages = jsonBook.getString("pages");
    Log.i("CodeChallenge", title + ", " + pages);
    }

Where am I going wrong with this code? Any help would be appreciated!

3 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

This has been a tricky one! See this older forum post about this same issue (with the same solution): http://teamtreehouse.com/forum/problem-with-android-parsing-json-code-challenge

Mike Costa
PLUS
Mike Costa
Courses Plus Student 26,361 Points

Ben,

Thank you for the response! That link helped!!! The Android courses are great, and I'm looking forward to many more! :)

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Awesome, so glad to hear it! Thanks for the feedback! :smile: