Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mururu/msgpack-elixir
MessagePack Implementation for Elixir / msgpack.org[Elixir]
https://github.com/mururu/msgpack-elixir
Last synced: 3 days ago
JSON representation
MessagePack Implementation for Elixir / msgpack.org[Elixir]
- Host: GitHub
- URL: https://github.com/mururu/msgpack-elixir
- Owner: mururu
- Created: 2013-02-02T13:01:26.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-06-07T03:50:45.000Z (over 7 years ago)
- Last Synced: 2024-11-01T08:34:09.117Z (7 days ago)
- Language: Elixir
- Homepage:
- Size: 367 KB
- Stars: 70
- Watchers: 8
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - MessagePack Implementation for Elixir. (Protocols)
- fucking-awesome-elixir - message_pack - MessagePack Implementation for Elixir. (Protocols)
- awesome-elixir - message_pack - MessagePack Implementation for Elixir. (Protocols)
README
# MessagePack for Elixir
[![Build Status](https://travis-ci.org/mururu/msgpack-elixir.png?branch=master)](https://travis-ci.org/mururu/msgpack-elixir)
## Installation
Add `:message_pack` as a dependency in your `mix.exs` file.
```elixir
defp deps do
[{:message_pack, "~> 0.2.0"}]
end
```## Usage
```elixir
# pack
MessagePack.pack([1,2,3]) #=> { :ok, <<147,1,2,3>> }
MessagePack.pack!([1,2,3]) #=> <<147,1,2,3>># unpack
MessagePack.unpack(<<147,1,2,3>>) #=> { :ok, [1,2,3] }
MessagePack.unpack!(<<147,1,2,3>>) #=> [1,2,3]# unpack_once
MessagePack.unpack_once(<<147,1,2,3,4>>) #=> {:ok, {[1, 2, 3], <<4>>}}
MessagePack.unpack_once!(<<147,1,2,3,4>>) #=> {[1, 2, 3], <<4>>}
```## Options
* `enable_string`
Support string type. This options is `false` by default.
```elixir
iex(1)> { :ok, bin } = MessagePack.pack(<<255>>)
{:ok, <<161, 255>>}
iex(3)> MessagePack.unpack(<<161, 255>>)
{:ok, <<255>>}
iex(4)> MessagePack.unpack(<<161, 255>>, enable_string: true)
{:error, {:invalid_string, <<255>>}}
```* `ext`
Support extention type.
See `test/message_pack_ext_test.exs`.
## License
MIT