# read-write-json

> read from a json file and write to a json file

Latest version **1.0.5** (published 2018-02-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install read-write-json
pnpm add read-write-json
yarn add read-write-json
bun add read-write-json
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2018-02-21 |
| First published | 2018-02-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Naman Agrawal |
| Maintainers | naman.agrawal |
| Keywords | read from json file, write to json file, updating value in json file, updating a specific value in json file, writing to a specfic json value, read key values from json file |

## Links

- npm: https://www.npmjs.com/package/read-write-json
- npm.io page: https://npm.io/package/read-write-json

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

- 1.0.5 (latest) — 2018-02-21
- 1.0.4 — 2018-02-21
- 1.0.3 — 2018-02-21
- 1.0.2 — 2018-02-21
- 1.0.1 — 2018-02-21
- 1.0.0 — 2018-02-21

## README

# JSON File Structure

	// Json file
	{
	  "users": [
		{
		  "id": "0011",
		  "name": "New User1"
		},
		{
		  "id": "789",
		  "name": "nuser2@test.com"
		}
	  ],
	  "isSuccess": "New Value"
	}

# Code to Read from JSON file and Write to JSON File

	const jsonData = require('read-write-json');

	fit('Read Write from JSON Package', function() {

	// --------Reading from JSON file----------------

	let data = jsonData.readJSONFile('path to json file');
	
	// To get all the data of json file
	console.log(data);
	
	// To get the specific key value
	console.log(data.isSuccess);
	
	// To get specific key value from an array
	console.log(data.users[0].id);

	// --------Writing to JSON file------------------

	// Updating key value
	data.isSuccess = 'New Value JSON';
	jsonData.writeJSONFile('path to json file', data);

	// Updating array key value
	data.users[0].id = '0011';
	jsonData.writeJSONFile('path to json file', data);
	
	});

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