See the written version of this tutorial for links to prerequisites and related tutorials: https://heynode.com/tutorial/readwrite-json-files-nodejs?utm_source=youtube&utm_medium=referral+&utm_campaign=YT+description&utm_content=read-write-json-iles-with-nodejs
When you want to store data between server restarts with Node, JSON files are a simple and convenient choice. Whether you are reading a config file or persisting data for your application, Node has some built-in utilities that make it easy to read and write JSON files. Using JSON files in your app can be a useful way to persist data. We will look at a few different methods for working with JSON files.
In this tutorial we'll:
- Read JSON data from disk
- Learn to use fs module to interact with the filesystem
- Persist data to a JSON file
- Use JSON.parse and JSON.stringify to convert data to and from JSON format
Heynode.com: The best online Node.js courses and tutorials to help you solve hard problems fast.
73 Comments