MessagePack with key extension
Space-efficient binary serialization format.
This includes an extension to remove xtra space for duplicate keys:
format name | first byte (in binary) | first byte (in hex) |
---|---|---|
fixext 1 | 11010100 | 0xd4 |
fixext 2 | 11010101 | 0xd5 |
where:
Y: 1-512 unit id of a map space
key: the string to save in that map space
+--------+--------+========+
| 0xd4 |YYYYYYYY| key |
+--------+--------+========+
Z: lookup the previously assigned key
+--------+--------+
| 0xd5 |ZZZZZZZZ|
+--------+--------+
this allows reused keys (i.e. for object serialization) to use up much less space.
I.e. if you have a list of objects like {id:1,name:"test"} you will save 4 bytes per iteration (one from id, and 3 from name)
// Got ArrayBuffer object
var packed = msgpack.pack( { the: { very: [ "long", true, "data" ], "structure" },
depth: "is", such: [ NaN, Inifinity ],
wow: new ArrayBuffer(100), is: 100 } );
// Got the original "such much" data structure
var data = msgpack.unpack(packed);
msgpack.MAX_DEPTH = 512
- adjust maximum allowable data depth