Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arangodb-community/velocy_pack
An Elixir parser and generator for VelocyPack v1
https://github.com/arangodb-community/velocy_pack
Last synced: 2 months ago
JSON representation
An Elixir parser and generator for VelocyPack v1
- Host: GitHub
- URL: https://github.com/arangodb-community/velocy_pack
- Owner: ArangoDB-Community
- License: other
- Created: 2017-12-20T08:00:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T12:27:05.000Z (10 months ago)
- Last Synced: 2024-10-06T14:18:57.756Z (3 months ago)
- Language: Elixir
- Homepage: https://github.com/arangodb/velocypack/blob/master/VelocyPack.md
- Size: 56.6 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VelocyPack
An Elixir parser and generator for [VelocyPack](https://github.com/arangodb/velocypack/blob/master/VelocyPack.md) v1.
The implementation is heavily inspired by [Jason](https://github.com/michalmuskala/jason) and
borrows some code (specifically the Codegen module).## Examples
```elixir
iex> {:ok, vpack} = VelocyPack.encode(10.2312514)
{:ok, <<27, 245, 78, 96, 149, 102, 118, 36, 64>>}
iex> VelocyPack.decode(vpack)
{:ok, 10.2312514}iex> vpack = VelocyPack.encode!(%{a: "a", b: %{bool: true, float: 10.2312514}})
<<11, 37, 2, 65, 97, 65, 97, 65, 98, 11, 26, 2, 68, 98, 111, 111, 108, 26, 69, 102, 108, 111, 97, 116, 27, 245, 78, 96, 149, 102, 118, 36, 64, 3, 9, 3, 7>>
iex> VelocyPack.decode!(vpack)
%{"a" => "a", "b" => %{"bool" => true, "float" => 10.2312514}}iex> VelocyPack.decode(<<11>>)
{:error, %VelocyPack.Error{message: "unexpected sequence", dump: nil}}iex> VelocyPack.decode!(<<11>>)
** (VelocyPack.Error) unexpected sequenceiex> VelocyPack.decode(<<11, 823891328731>>)
{:error, %VelocyPack.Error{message: "unexpected byte", dump: "<<0xDB>>"}}iex> VelocyPack.decode!(<<11, 823891328731>>)
** (VelocyPack.Error) unexpected byte: <<0xDB>>
```