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

Android

Mike Costa
PLUS
Mike Costa
Courses Plus Student 26,362 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,362 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: