MessagePack (de)serializer implementation for Erlang / msgpack.org[Erlang]
Go to file
2016-03-21 02:09:11 +09:00
eqc Introduce rebar3 eqc plugin 2015-12-11 11:32:39 +09:00
include Default map unpacker function is now maps 2015-12-08 15:07:45 +09:00
src Fix unpacking str8 when enable_str=false. 2016-02-02 16:30:12 +01:00
test Remove duplicated tests 2015-12-11 11:40:00 +09:00
.eqc_ci Fix quickcheck-ci.com test 2015-12-11 11:32:39 +09:00
.gitignore More cleaner way to keep compatibility with rebar 2.x 2016-03-11 01:21:02 +09:00
.travis.yml Fix travis-ci build 2016-01-25 22:35:48 +09:00
AUTHORS Release notes 2015-03-11 22:34:58 +09:00
dialyzer.ignore-warnings fix some dialyzing 2014-01-18 01:14:53 +09:00
EQC_CI_LICENCE.txt add quickcheck-ci.com files 2015-12-11 11:32:39 +09:00
LICENSE-2.0.txt add license terms and a bit cosme 2011-05-02 17:29:00 +09:00
Makefile More cleaner way to keep compatibility with rebar 2.x 2016-03-11 01:21:02 +09:00
README.md Draft of new optional style 2016-03-21 02:09:11 +09:00
rebar.config More cleaner way to keep compatibility with rebar 2.x 2016-03-11 01:21:02 +09:00
rebar.lock Move to rebar3 2015-12-08 13:04:46 +09:00

MessagePack Erlang

Travis

Drone.io

Prerequisites for runtime

Erlang/OTP, >= 17.0 Also based on the new msgpack spec 232a0d.

edit rebar.config to use in your application

{deps, [
  {msgpack, ".*",
    {git, "git://github.com/msgpack/msgpack-erlang.git", {branch, "master"}}}
]}.

Simple deserialization

Ham = msgpack:pack(Spam),
{ok, Spam} = msgpack:unpack(Ham).

Stream deserialization

{Term0, Rest0} = msgpack:unpack_stream(Binary),
{Term1, Rest1} = msgpack:unpack_stream(Rest0),
...

Options, for packing and unpacking

{spec, new|old}

Both packing and unpacking.

old spec:

OldHam = msgpack:pack(Spam, [{enable_str,false}]),
{ok, Spam} = msgpack:unpack(OldHam, [{enable_str,false}]).

{allow_atom, none|pack}

Only in packing

{known_atoms, [atom()]}

Both in packing and unpacking

{str, as_binary|as_list|as_validated_list}

Both in packing and unpacking. Only available at new spec.

Now this supports string type!

Opt = [{enable_str, true}]
{ok, "埼玉"} = msgpack:unpack(msgpack:pack("埼玉", Opt), Opt).
 => {ok,[22524,29577]}

{map_format, maps|jiffy|jsx}

Both at packing and unpacking.

msgpack:pack(#{ <<"key">> => <<"value">> }, []).
msgpack:pack({[{<<"key">>, <<"value">>}]}, [{format, jiffy}]),
msgpack:pack([{<<"key">>, <<"value">>}], [{format, jsx}]).

{ext, {msgpack_ext_packer(), msgpack_ext_unpacker()}|module()}

At both.

Now msgpack-erlang supports ext type. Now you can serialize everything with your original (de)serializer. That will enable us to handle erlang- native types like pid(), ref() contained in tuple(). See test/msgpack_ext_example_tests.erl for example code.

Packer = fun({ref, Ref}, Opt) when is_reference(Ref) -> {ok, {12, term_to_binary(Ref)}} end,
Unpacker = fun(12, Bin) -> {ok, {ref, binary_to_term(Bin)}} end,
Ref = make_ref(),
Opt = [{ext,{Packer,Unpacker}}],
{ok, {ref, Ref}} = msgpack:unpack(msgpack:pack({ref, Ref}, Opt), Opt).

License

Apache License 2.0

Release Notes

0.5.0

  • Renewed optional arguments to pack/unpack interface.

0.4.0

  • Deprecate nil
  • Moved to rebar3
  • Promote default map unpacker as default format when OTP is >= 17
  • Added QuickCheck tests
  • Since this version OTP older than R16B03-1 are no more supported

0.3.5 / 0.3.4

  • 0.3 series will be the last versions that supports R16B or older versions of OTP.
  • OTP 18.0 support
  • Promote default map unpacker as default format when OTP is >= 18

0.3.3

  • Add OTP 17 series to Travis-CI tests
  • Fix wrong numbering for ext types
  • Allow packing maps even when {format,map} is not set
  • Fix Dialyzer invalid contract warning
  • Proper use of null for jiffy-style encoding/decoding

0.3.2

  • set back default style as jiffy
  • fix bugs around nil/null handling

0.3.0

  • supports map new in 17.0
  • jiffy-style maps will be deprecated in near future
  • set default style as map

0.2.8

0.2 series works with OTP 17.0, R16, R15, and with MessagePack's new and old format. But does not support map type introduced in OTP 17.0.

It also supports JSX-compatible mode.