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

serialize-json

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serialize-json

A serialize algorithm for JSON

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35K
decreased by-20.57%
Maintainers
1
Weekly downloads
 
Created
Source

serialize-json

A serialize algorithm for JSON

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Introduction

  • Support serialize JSON to Buffer, and deserialize Buffer to JSON

    • [√] Boolean
    • [√] String
    • [√] Number
    • [√] Null
    • [√] Undefined
    • [√] Date
    • [√] Buffer
    • [√] Error
    • [√] Plain Object
    • [×] Function
    • [×] RegExp
    • [×] Symbol
  • Inspire by jsonpack, it can compress to 55% of original size if the data has a recursive structure

Install

$ npm install serialize-json --save

Node.js >= 4.0.0 required

Usage

let json = {
  a: 'a',
  b: 123,
  c: 123.456,
  d: [ 1, 2, 3 ],
  e: true,
  f: null,
  g: undefined,
  h: new Date(),
  i: new Buffer('this is a buffer'),
  j: new Error('this is a error'),
};
const buf = JSON.encode(json);
const result = JSON.decode(buf);
assert.deepEqual(result, json);

API

  • encode(json) serialize a json object
  • decode(buf) deserialize a buffer to json

Keywords

FAQs

Package last updated on 29 Oct 2018

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