https://github.com/bajankristof/bson
BSON implementation in Erlang
https://github.com/bajankristof/bson
Last synced: 16 days ago
JSON representation
BSON implementation in Erlang
- Host: GitHub
- URL: https://github.com/bajankristof/bson
- Owner: bajankristof
- License: apache-2.0
- Created: 2020-12-19T12:26:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-12T16:45:37.000Z (almost 2 years ago)
- Last Synced: 2025-02-16T01:25:49.626Z (2 months ago)
- Language: Erlang
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bson
===BSON implementation in Erlang.
[Read the docs!](https://github.com/bajankristof/bson/blob/main/doc/bson.md)
Build
---$ rebar3 compile
Getting started
---```erlang
-include_lib("bson/include/bson.hrl").
```### `bson:encode`
```erlang
bson:decode(<<22,0,0,0,7,95,105,100,0,95,220,150,226,21,1,11,30,59,151,141,20,0>>).
%% #{<<"_id">> => #'bson.objectid'{value = <<95,220,150,226,21,1,11,30,59,151,141,20>>}}
```### `bson:decode`
```erlang
bson:encode(#{<<"_id">> => bson:binary_to_objectid(<<"5fdc96e215010b1e3b978d14">>)}).
%% {<<22,0,0,0,7,95,105,100,0,95,220,150,226,21,1,11,30,59,151,141,20,0>>, <<>>}
```### `bson:construct`
```erlang
bson:construct([{int32, 1}, {document, #{}}]).
%% <<1,0,0,0,5,0,0,0,0>>
```### `bson:destruct`
```erlang
bson:destruct([int32, document], <<1,0,0,0,5,0,0,0,0>>).
%% {[1, #{}], <<>>}
```