https://github.com/animatedcreativity/node-file-json
Read JSON from a file and work on it dynamically. You can even use the JSON file as a small database. If file does not exist, one will be created for you.
https://github.com/animatedcreativity/node-file-json
Last synced: 4 months ago
JSON representation
Read JSON from a file and work on it dynamically. You can even use the JSON file as a small database. If file does not exist, one will be created for you.
- Host: GitHub
- URL: https://github.com/animatedcreativity/node-file-json
- Owner: animatedcreativity
- License: mit
- Created: 2019-01-20T10:35:32.000Z (over 7 years ago)
- Default Branch: glitch
- Last Pushed: 2019-01-21T03:42:38.000Z (over 7 years ago)
- Last Synced: 2025-10-10T15:23:47.882Z (8 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-file-json
Read JSON from a file and work on it dynamically. You can even use the JSON file as a small database. If file does not exist, one will be created for you.
**Usage:**
Load JSON file, if it does not exist, it will be created automatically.
```
var fileJson = require("node-file-json");
var json = new fileJson();
json.load("product.json");
```
Modify JSON data
```
json.data.property1 = "First property";
json.data.property2 = {name: "Product name", details: "These are some details."};
```
Save JSON data
```
json.save();
```
Data will be saved in the file as defined in .load() to be read any time.
If any errors occur during loading/creating JSON file, check console log.
JSON in file is saved properly with indents. To modify indent value, add it to options, example:
```
json.load("product.json", {indent: 4});
```
Clear JSON data
```
json.clear();
```