Package detail

ubjson

Sannis600.0.8

Universal Binary JSON packer/unpacker for Node.js

ubjson, universal binary json, json, binary

readme

Node-UBJSON

NPM version BS CS


Universal Binary JSON packer/unpacker for Node.js.

Check out the Github repo for the source code. Visit module site for API docs and examples. Extra information available in wiki.

Installation

You can install this module via npm:

$> npm install ubjson

Also you can build latest source code from repository, see below.

Usage example

// Preallocate buffer
var buffer = new Buffer(1024);

// Synchronous pack
var offset = UBJSON.packToBufferSync(jsonObject, buffer);
buffer = buffer.slice(0, offset);

// Asynchronous pack
UBJSON.packToBuffer({"key": "value"}, buffer, function (error, offset) {
  if (error) {
    throw error;
  }

  buffer = buffer.slice(0, offset);

  // Asynchronous unpack
  UBJSON.unpackBuffer(buffer, function (error, value) {
    if (error) {
      throw error;
    }

    done();
  });
});

Full API documentation.

Contributing

To contribute any patches, simply fork this repository using GitHub and send a pull request to me. Thanks!

All information about development use and contribution is placed in the DEVELOPMENT file.

License

MIT license. See license text in file LICENSE.

changelog

Changelog (revision history) for node-ubjson, the Universal Binary JSON packer/unpacker for Node.js.

Version 0.0.8

  • Use long npm module for int64 values storing
  • Write safe 64-bit integers as INT64 UBJSON types
  • Add usage examples to readme
  • Few tests added

Version 0.0.7

  • No-Op marker support
  • Add code coverage report via Coveralls
  • Add API docs to GH pages
  • Use JSHint for linting code
  • Fix TMP dir creation on OS X
  • Support latest Node.js versions

Version 0.0.6

  • Parser should return error for malformed input
    • Now pass error to callback for unpackBuffer() and packToBuffer()
    • Call unpackBuffer() callback only once
    • unpackBuffer() callback error object should contain remainingData
    • Error object should contain collectedData for malformed arrays and objects
    • Stream now emit 'error' event on malformed input
  • Add global and per-stream send buffer length setting with 'rw' interface
  • Write stream should split long strings
  • Implement int64/L support

Version 0.0.5

  • Implement stream reader/writer
  • Improve readme, add API docs generated from PDoc comments
  • Split module into separate files

Version 0.0.4

  • Support for unknown length containers unpacking

Version 0.0.3

  • Fix object/o type marker
  • Support for byte/B, int16/i and int32/I values
  • Support for float/d and double/D values
  • Partial support for huge/h and huge/H values
  • Add MediaContent.json test from universal-binary-json-java

Version 0.0.2

  • Support for string/s and string/S values
  • Support for object/o and object/O containers

Version 0.0.1

  • Packer/unpacker using node-strtok
  • Support for null/Z, true/T, false/F values
  • Support for array/a and array/A containers