-
-
Notifications
You must be signed in to change notification settings - Fork 37.3k
"json" encoding support for fs.readX functions #44150
Copy link
Copy link
Closed as not planned
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
What is the problem this feature will solve?
The
JSON.parse(fs.readFileSync(path)),fs.readFile(path, "utf-8", res => { res = JSON.parse(res); /* ... */ })look just way too long and complex.What is the feature you are proposing to solve the problem?
The "json" encoding for the builtin
fsmodule. Here's how it might look like:As you can see, it's much shorter and more clear.
What alternatives have you considered?
As I've shown above,
JSON.parseis a variant right now, but it's just way too long. There's alsor-jsonpackage, but having a separate package just for reading JSON files takes much more space.