Ported from msgpack