# parse-json-from-buffer

> parse a json form a buffer

Latest version **1.0.8** (published 2022-01-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install parse-json-from-buffer
pnpm add parse-json-from-buffer
yarn add parse-json-from-buffer
bun add parse-json-from-buffer
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2022-01-27 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | thomas trividic |
| Maintainers | fosk06 |

## Links

- npm: https://www.npmjs.com/package/parse-json-from-buffer
- Repository: https://github.com/fosk06/parseJsonFromBuffer
- Homepage: https://github.com/fosk06/parseJsonFromBuffer#readme
- Issues: https://github.com/fosk06/parseJsonFromBuffer/issues
- npm.io page: https://npm.io/package/parse-json-from-buffer

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^12.12.3

## Recent versions

- 1.0.8 (latest) — 2022-01-27
- 1.0.7 — 2019-10-31
- 1.0.6 — 2019-10-31
- 1.0.5 — 2019-10-31
- 1.0.4 — 2019-10-31
- 1.0.3 — 2019-10-31
- 1.0.2 — 2019-10-31
- 1.0.1 — 2019-10-31
- 1.0.0 — 2019-10-31

## README

# parseJsonFromBuffer

A very simple module that transform a buffer to a JS object.
It takes a buffer, convert it to string then parse the JSON and return the javascript object.

## Usage

### Javascript

```javascript
const {parseJsonFromBuffer,encodeObjectToString} = require('parse-json-from-buffer');
const secrets = {secretOne: "changeMe", secretTwo: "changeMeToo"};
// encode your js object (must be allow JSON.STRINGIFY)
const encodedSecrets = encodeObjectToString(secrets, 'base64');

const testBuffer = Buffer.from(encodedSecrets) // json stringified base64 string
// revert the process
const result = parseJsonFromBuffer(testBuffer, 'base64') // output {secretOne: "changeMe", secretTwo: "changeMeToo"};
```

### TypeScript

```typescript
import  parseJsonFromBuffer,encodeObjectToString  from 'parse-json-from-buffer';
const secrets = {secretOne: "changeMe", secretTwo: "changeMeToo"};
// encode your js object (must be allow JSON.STRINGIFY)
const encodedSecrets = encodeObjectToString(secrets, 'base64');

const testBuffer = Buffer.from(encodedSecrets) // json stringified base64 string
// revert the process
const result = parseJsonFromBuffer(testBuffer, 'base64') // output {secretOne: "changeMe", secretTwo: "changeMeToo"};
```

## Test

You can run tests with this command:

```bash
npm test
```

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