Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-json-from-buffer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-json-from-buffer

parse a json form a buffer

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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

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

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:

npm test

FAQs

Package last updated on 27 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc