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

JavaScript Node.js Basics (2014) Building a Command Line Application Parsing JSON

Stage 2 buiding cmd line App

var jsonString = '{"name": "Andrew", "languages": ["javascript", "swift", "java", "ruby", "html", "css", "qbasic"]}'; var jsonObject = JSON.parse(body); console.dir(jsonObject);

I have error

var jsonString = '{"name": "Andrew", "languages": ["javascript", "swift", "java", "ruby", "html", "css", "qbasic"]}'; var jsonObject = JSON.parse(jsonObject);

3 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Ellie,

Try removing your console.dir declaration as it's not required by the challenge.

Happy coding!

var jsonString = '{"name": "Andrew", "languages": ["javascript", "swift", "java", "ruby", "html", "css", "qbasic"]}'; var jsonObject = JSON.parse(jsonObject);

I get error again.

Chris Shaw
Chris Shaw
26,676 Points

Sorry, I missed the minor typo you also have, instead of jasonObject you should have jsonObject, notice the a no longer the second character, also body should be jsonString.

var jsonObject = JSON.parse(jsonString);

I fixed the typo. still same error.

Chris Shaw
Chris Shaw
26,676 Points

Your jsonObject variable is still wrong, you should be parsing jsonString.

var jsonObject = JSON.parse(jsonString);

var jsonObject = JSON.parse(jsonString);

Still error. I tried to refresh browser too.