A serialize algorithm for JSON
A serialize algorithm for JSON
Support serialize JSON to Buffer, and deserialize Buffer to JSON
Inspire by jsonpack, it can compress to 55% of original size if the data has a recursive structure
$ npm install serialize-json --save
Node.js >= 4.0.0 required
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);
encode(json)
serialize a json objectdecode(buf)
deserialize a buffer to json