Socket
Socket
Sign inDemoInstall

json-buffer

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-buffer

JSON parse & stringify that supports binary via bops & base64


Version published
Maintainers
1
Weekly downloads
27,265,301
decreased by-0.95%
Bundle size
469 bytes
Minified + gzipped

Weekly downloads

Package description

What is json-buffer?

The json-buffer npm package is designed to serialize and deserialize JSON data that includes binary Buffers. Normally, JSON.stringify() will lose the Buffer information, converting Buffers to objects. json-buffer preserves the Buffer data by encoding it as a base64 string when serializing and then decoding it back to a Buffer when deserializing.

What are json-buffer's main functionalities?

Serialization

Converts a JavaScript object with Buffers into a JSON string, encoding Buffers as base64 strings.

{"data":"VGhpcyBpcyBhIHRlc3QgYnVmZmVy"}

Deserialization

Parses a JSON string that contains base64 encoded Buffers, converting them back into Buffer objects.

{"type":"Buffer","data":[84,104,105,115,32,105,115,32,97,32,116,101,115,116,32,98,117,102,102,101,114]}

Other packages similar to json-buffer

Readme

Source

json-buffer

JSON functions that can convert buffers!

build status

testling badge

JSON mangles buffers by converting to an array... which isn't helpful. json-buffers converts to base64 instead, and deconverts base64 to a buffer.

var JSONB = require('json-buffer')
var Buffer = require('buffer').Buffer

var str = JSONB.stringify(Buffer.from('hello there!'))

console.log(JSONB.parse(str)) //GET a BUFFER back

License

MIT

FAQs

Last updated on 10 Sep 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc