MessagePack is a binary-based JSON-like serialization library.
MessagePack for D is a pure D implementation of MessagePack.
- Small and High performance
- Zero copy serialization / deserialization
- Stream deserializer / Direct-conversion deserializer
- Support D features(Range, Tuple, real type)
real type is D only. Don't use real-type to communicate other languages. In addition, Unpacker raises exception if loss of precision occures.
- No subclass through super class reference serialization(API design phase)
- No circular references support
msgpack-d is only one file. Please copy src/msgpack.d onto your project.
msgpack-d is very simple to use:
import std.file;
import msgpack;
struct S { int x; float y; string z; }
void main()
{
S input = S(10, 25.5, "message");
// serialize data
ubyte[] inData = msgpack.pack(input);
// write data to a file
write("file.dat", inData);
// read data from file
ubyte[] outData = cast(ubyte[])read("file.dat");
// unserialize data
S target;
msgpack.unpack(outData, target);
// verify data is the same
assert(target.x == input.x);
assert(target.y == input.y);
assert(target.z == input.z);
}
See the example directory for more samples.
-
MessagePack official site
-
Github issue
-
Other language versions are here
Copyright (c) 2010- Masahiro Nakagawa
Distributed under the Boost Software License, Version 1.0.