json-hpack

0.0.2 • Public • Published

json.hpack

Nodejs Implementation of WebReflection/json.hpack Source

Explanation

Installation

$ npm install json-hpack

or specify in package.json as dependency

Usage

with express

// Add Prototype to JSON, So no need to use variable
require('json-hpack')
 
// or
json_hpack = require('json-hpack')
 
 
var json = [{
    name : "Andrea",
    age : 31,
    gender : "Male",
    skilled : true
}, {
    name : "Eva",
    age : 27,
    gender : "Female",
    skilled : true
}, {
    name : "Daniele",
    age : 26,
    gender : "Male",
    skilled : false
}]
 
// Packing
packed_json = JSON.hpack(json);
 
console.log("Packed JSON",packed_json);
// Packed JSON [ [ 'name', 'age', 'gender', 'skilled' ],
// [ 'Andrea', 31, 'Male', true ],
// [ 'Eva', 27, 'Female', true ],
// [ 'Daniele', 26, 'Male', false ] ]
 
unpacked_json = JSON.hunpack(packed_json);
 
console.log("Unpacked JSON:",unpacked_json)
// Unpacked JSON [ { name: 'Andrea', age: 31, gender: 'Male', skilled: true },
//                 { name: 'Eva', age: 27, gender: 'Female', skilled: true },
//                 { name: 'Daniele', age: 26, gender: 'Male', skilled: false } ]
 

json.hpack is now JSONH, check new repository

json.hpack has been deprecated in favor or better practices to obtain good average compression over best performances for both client and server. Please consider to switch to new JSONH project since this one is not actively maintained anymore, thanks.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    18
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    18
  • 0.0.1
    1

Package Sidebar

Install

npm i json-hpack

Weekly Downloads

13

Version

0.0.2

License

ISC

Last publish

Collaborators

  • manjeshpv