# 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.

Latest version **0.0.8** (published 2019-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-file-json
pnpm add node-file-json
yarn add node-file-json
bun add node-file-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2019-01-21 |
| First published | 2019-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 8.x |
| Dependencies | 1 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | rehmat |
| Keywords | node, file, JSON, dynamic, database |

## Links

- npm: https://www.npmjs.com/package/node-file-json
- Repository: https://github.com/animatedcreativity/node-file-json
- Homepage: https://github.com/animatedcreativity/node-file-json#readme
- Issues: https://github.com/animatedcreativity/node-file-json/issues
- npm.io page: https://npm.io/package/node-file-json

## Dependencies (1)

- [node-sanitize-options](https://npm.io/package/node-sanitize-options.md) ^0.0.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.8 (latest) — 2019-01-21
- 0.0.7 — 2019-01-20
- 0.0.6 — 2019-01-20
- 0.0.5 — 2019-01-20
- 0.0.4 — 2019-01-20
- 0.0.3 — 2019-01-20
- 0.0.2 — 2019-01-20
- 0.0.1 — 2019-01-20

## 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.<br/>
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();
```

---
_Source: https://npm.io/package/node-file-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
