Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

tomaon/messagepack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Installation

Add messagepack to your list of dependencies in mix.exs:

def deps do
  [{:messagepack, "== x.y.z"}]
end

or rebar.config:

{deps, [
        {messagepack, "x.y.z"},
       ]}.

Example

elixir:

iex(1)> defmodule Example do
...(1)>   defstruct [:compact, :schema]
...(1)> end
{:module, Example, <<...>>, %Example{compact: nil, schema: nil}}
iex(2)> x = %Example{:compact => true, :schema => 0}
%Example{compact: true, schema: 0}
iex(3)> b = Messagepack.encode!(x)
<<...>>
iex(4)> byte_size(b)
44
iex(5)> x = Messagepack.decode!(b)
%Example{compact: true, schema: 0}

erlang:

1> X = #{compact => true, schema => 0}.
#{compact => true,schema => 0}
2> {ok, B} = messagepack:encode(X).
{ok,<<130,167,99,111,109,112,97,99,116,195,166,115,99,104,101,109,97,0>>}
3> byte_size(B).
18
4> {ok, X} = messagepack:decode(B).
{ok,#{compact => true,schema => 0}}

License

Apache-2.0