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.
Ramrakesh Azhagesan7,238 Points
Data Parsing final Step
I am getting the error ""bummer! make sure you write each book to the log exactly as specified in the instructions"
i need the format : book title, a comma, a space, and the number of pages.
example : 'book title 1, 300'.
my code output
Log.i("CodeChallenge",title + ", " + pages);
String title = jsonData.getString("title");
int pages = jsonData.getInt("pages");
I had an issue with working through this example for a time as well. This looks exactly like my answer except for: Instead of passing it the jsonData.get line I used the JSONObject that we both createad inside the for loop
So... String title = jsonBook.getString("title");
Instead of: int pages = jsonData.getInt("pages");
I passed it as a string variable. So I changed you're line into:
String pages = jsonBook.getString("pages"); and it worked for me.
However, now seeing that the data.json page does not use double quotes your answer may be more correct.