| CARVIEW |
mojombo / bert.erl
- Source
- Commits
- Network (3)
- Issues (1)
- Downloads (2)
- Wiki (1)
- Graphs
-
Branch:
master
click here to add a description
click here to add a homepage
-
Branches (1)
- master ✓
- Tags (2)
Pledgie Donations
Once activated, we'll place the following badge in your repository's detail box:
Erlang BERT encoder/decoder — Read more
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Jan 07 16:07:31 -0800 2010 | convert to standard erlang package structure an... [Tom Preston-Werner] |
| |
LICENSE | Thu Jan 07 16:07:31 -0800 2010 | convert to standard erlang package structure an... [Tom Preston-Werner] |
| |
README.md | Thu Jan 07 16:07:31 -0800 2010 | convert to standard erlang package structure an... [Tom Preston-Werner] |
| |
Rakefile | Thu Jan 07 16:07:31 -0800 2010 | convert to standard erlang package structure an... [Tom Preston-Werner] |
| |
src/ | Thu Jan 07 16:11:58 -0800 2010 | release 1.1.0 [Tom Preston-Werner] |
| |
test/ | Thu Jan 07 16:07:31 -0800 2010 | convert to standard erlang package structure an... [Tom Preston-Werner] |
Erlang BERT encoder/decoder. See https://bert-rpc.org for full spec.
Watch and contribute to this module at https://github.com/mojombo/bert.erl.
This module is Semantic Versioning (https://semver.org) compliant.
The following types can be automatically encoded and decoded. See https://www.erlang.org/eeps/eep-0008.html for type definitions.
integer() -> BERT integer float() -> BERT float atom() -> BERT atom tuple() -> BERT tuple list() -> BERT list or BERT bytelist string() -> BERT list or BERT bytelist (you probably want binary) binary() -> BERT binary [] -> BERT nil (complex) bool() -> BERT boolean (complex) dict() -> BERT dict (complex)
Because times and regular expressions types cannot be automatically detected, you must encode and decode those types manually.
To encode Erlang terms to BERT binaries, use:
encode(term()) -> binary().
To decode BERT binaries to Erlang terms, use:
decode(binary()) -> term().
Examples
% Encode a variety of literal Erlang terms:
bert:encode([42, 3.14, banana, {xy, 5, 10}, <<"robot">>, true, false]).
% -> <<131,108,0,0,0,7,97,42,99,51,46,49,52,48,48,48,48,48,48,...>>
% Encode an Erlang dict() record:
D0 = dict:new().
D1 = dict:store(apple, red, D0).
bert:encode(D1).
% -> <<131,104,9,100,0,4,100,105,99,116,97,0,97,16,97,16,97,8,...>>
% Decode a BERT binary:
bert:decode(<<131,108,0,0,0,7,97,42,99,51,46,49,52,...>>).
% -> [42, 3.14, banana, {xy, 5, 10}, <<"robot">>, true, false]
