BOSS serialization protocol

GitHub:  sergeych/boss_protocol

BOSS (Binary Object Serialization Specification) protocol is a binary-effective serialization

Supports stream mode with no caching, as well as regular cached mode.

BOSS is the bit-effective, platform-independent streamable and traversable typed binary protocol. Allows to effectively store small or any sized integers, strings or binary data of any size, floats and doubles, arrays and hashes and time objects in a very effective way.

The protocol allows to effectively store:

  • text strings and binary data of absolutely any size,
  • signed integers of absolutely any size (including small ones – using variable-length integers),
  • arrays and hashes with no limit on items and overall gross size.

It caches repeated objects and stores/restores links to objects. It is desirable to use build-in compression when appropriate.

“Streamable” means that you can use a pipe (for example TCP/IP), put the object at one side and load it on other, one-by-one, and caching and links will be restored properly.

Initially, this protocol was intended to be used in secure communications. Its main goal was to send data effectively, acting as a great replacement for JSON or other serialization protocols. For example, using BOSS, a typical JSON document is reduced in size about twice.

BOSS protocol also allows to transparently compress its representations.

BOSS also supports “stream mode” that lacks tree reconstruction but could be effectively use when implementing long-living streams (e.g. stream protocols). In regular mode it causes unlimited cache grows as BOSS would try to reconstruct all possible references to already serialized objects. In the stream mode only strings are cached, and cache size and capacity are dynamically limited. BOSS writes the stream mode marker and handles stream mode on receiving end automatically.

Supported types:

  • Signed integers of any length;
  • Signed floats and doubles (4 or 8 bytes);
  • Boolean values (true/false);
  • UTF-8 encoded texts, any length;
  • Binary data, any length;
  • Date objects (date and time with 1 second resolution);
  • Arrays with any number of mixed type elements;
  • Hashes with any keys and values and unlimited length;
  • Reference to the object that already was serialized (unless in stream mode).