serialize-json
A serialize algorithm for JSON
Last updated 6 years ago by gxcsoccer .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install serialize-json 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.3                                ...           latest (6 years ago)

4 Versions

  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (8)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE