So in a pinch if you know the relative path to the json that you want to load, and the json is property formated json could be parsed just like this.
Although this might work okay there are still some drawbacks when it comes to error handling at least in the event that the json file is not there, or is not property formated for whatever the reason. So lets take a look at some other options.
This way if an error happens when loading a json file I can write some logic that will do something in the event that an error occurs.
So require can be used to import json but it can not be used to export it. For this something more will need to be used on top of just require. The file system module in node.js can be used to read and write files and do a wide range of additional file io related tasks. So in this section I will be going over a simple example that can be used as a way to write some json to a file using the file system write method and the JSON stringify method.