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 Express Basics Parameters, Query Strings, and Modularizing Routes Using Data and Route Parameters

Viola Chyu
Viola Chyu
6,432 Points

How exactly do you include JSON in Node?

As Chalkey said in this video at 03:13, quote, “You can also include JSON directly in Node.It reads the text file and then parses the text and coverts it into a JSON object so you don't have to call json.parse.” , while requiring data from the jsonfile we just created. 
 What does he mean by that? And how can it be done?

Thanks in advance for helping!

1 Answer

This might help....

https://www.geeksforgeeks.org/how-to-read-and-write-json-file-using-node-js/

I find that Andrew can be really lax with his descriptions and that doesn't dive deeper into the detail as to why or how you can do a specific tasks.

I interpreted what he said as in express this is how you can get json data into your app but you can also use pure node which but you have to do the heavy lifting yourself, i.e. parse the json as per the link above.

Hope that helps, else if you understand it please let me know!