-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Description
Is your feature request related to a problem? Please describe.
Reading a JSON file is a very common need. It would be nice to have a convenience method for it.
In addition to making it easier to do this common task, it could also:
For example, I have a package for this which is quite popular and has 700 dependents, so it's clearly a need for it: https://www.npmjs.com/package/load-json-file
It is also quite a popular question on Stack Overflow: https://stackoverflow.com/questions/10011011/using-node-js-how-do-i-read-a-json-file-into-server-memory?rq=1
Having it in Node.js core would also help reduce dependency trees, which would in turn reduce npm install
times and node_modules
bloat. It would also improve DX by having better syntax errors.
Describe the solution you'd like
I propose adding a fs.readJson()
and fs.readJsonSync()
method.
Describe alternatives you've considered
Continue using https://www.npmjs.com/package/load-json-file
I didn't want this to dilute the proposal, but one future enhancement to this could be to make the JSON parsing fully async by doing it in a worker.