Name: serialize-json
Owner: node_modules
Description: A serialize algorithm for JSON
Created: 2017-02-03 14:18:58.0
Updated: 2018-01-25 04:20:57.0
Pushed: 2017-12-13 14:58:09.0
Size: 13
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A serialize algorithm for JSON
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
m install serialize-json --save
Node.js >= 4.0.0 required
json = {
'a',
123,
123.456,
[ 1, 2, 3 ],
true,
null,
undefined,
new Date(),
new Buffer('this is a buffer'),
new Error('this is a error'),
t buf = JSON.encode(json);
t result = JSON.decode(buf);
rt.deepEqual(result, json);
encode(json)
serialize a json objectdecode(buf)
deserialize a buffer to json