1.0.1 • Published 2 years ago

dcjson v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

dcjson

dcjson is a lightweight node module to Disassemble and Compress JSON object.

Installation

npm install dcjson

Documentation

Compress

dcjson.compress(json: Object): Uint8Array

Example

const dcjson = require("dcjson");
const fs = require("fs");

const input = fs.readFileSync(`${__dirname}/test.json`, "utf-8");
const json = JSON.parse(input);

const output = dcjson.compress(json);
fs.writeFileSync(`${__dirname}/test_compressed.json.dc`, output);

Decompress

dcjson.decompress(buffer: Uint8Array): Object

Example

const dcjson = require("dcjson");
const fs = require("fs");

const input = fs.readFileSync(`${__dirname}/test_compressed.json.dc`);

const output = dcjson.decompress(input);
const json = JSON.stringify(output, null, "\t");
fs.writeFileSync(`${__dirname}/test_decompressed.json`, json);

Performance

Tested 10 times using JSON file of large scale.(712.14KB) |Library|Compress|Decompress |:-:|:-:|:-:| |dcjson|5.803s / 121.9KB|0.048s| |msgpack|0.042s / 304.3KB|0.050s| |LZ4|0.013s / 99.31KB|0.017s| |-|-|-| |dcjson + LZ4|70.32KB|-| |dcjson + msgpack|83.66KB|-|

Changelogs

v1.0.1

  • Fixed an issue that could encode arrays wrongly.

v1.0.0

  • Release