Skip to main content

class BJSON

BJSON provides packaging and unpackaging of JSON in binary form.

constructor:

  • let bjson = new BJSON() - creates binary JSON pack/unpack context.

methods:

  • bjson.pack(data) : ArrayBuffer

    Serializes data to the ArrayBuffer.

  • bjson.unpack(blob: ArrayBuffer, receiver:function(data))

    Restores data from BJSON blob.

example:

This code packages and restores {hello:"world"} object:

let bjson = new BJSON();
// packaging:
let blob = bjson.pack({hello:"world"});
// unpackaging:
bjson.unpack(blob, data => {
console.assert(data.hello =="world");
});