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 trialOnur Çevik
2,390 PointsCode Challenge Help
Hey guys. I couldn't complete the code challenge, but not sure why. I think the issue is with JSONObject parameters, but I couldn't solve it. Would appreciate a help, and a quick explanation why mine did not work. Thanks.
JSONObject jsonData = new JSONObject(data);
String name = jsonData.getString("name");
String publisher = jsonData.getString("publisher");
String language = jsonData.getString("language");
Edit: Do I even need to add a class, method etc.? I haven't tried that to be honest, and too lazy to try :P
1 Answer
Seth Kroger
56,413 PointsAccording to the challenge "The data in the file data.json has been loaded into a JSONObject named jsonData" already so you don't need to declare jsonData as a new JSONObject. The challenge should pass if you remove that line.
[also editing for formatting]
Onur Çevik
2,390 PointsOnur Çevik
2,390 PointsOh, silly mistake. Thanks alot man. And by the way, did I declare the JSONObject correctly there? Just to make sure I completely understood it.