Diff: [root] @ af543b0d0d2 | faq | css

rbson from ancient archives

File created: 33188 code/rbson [Diff]

diff --git a/code/rbson b/code/rbson
new file mode 100644
index 0000000..2587411
-- /dev/null
++ b/code/rbson
@@ -0,0 +1,84 @@
h1. RBSON format specification

h3. Size

This field can hold infinite amounts of data in 4-byte chunks and is uses to define sizes of other fields.

|3 b|Data|
|1 bit|If it's 1, there's one more chunk after that one|
|7 bit|Unused|
||This section repeats|

On last chunk, all Data pieces are concatenated and converted to integer.

h3. Natural

This type is used internally to represent natural numbers. It's equal to Data, except is contents are interpreted as unsigned integer and it does not have a type code.

|variable|Size|
|variable|Data|

h3. Array

h4. Intro

|1 b|0x04|Type|
|variable|Size|Size till the end of array|

h4. Header

|variable|Size|Size till the end of header|
|variable|Integer|Offset from start of Body section to start of N-th array element, repeats|

h4. Body

|variable|RBSON|N-th Array entry, repeats|

h3. Data

This type is similar to JSON's String, it's a sequence of bytes.

|1 b|0x01|Type|
|variable|Size|Size of bytestring|
|variable|Data|Bytestring|

h3. Object

This type is similar to JSON's Object. It's list of key-value pairs, where keys are bytestrings and value can be any RBSON type.

h4. Intro

|1 b|0x02|Type|
|variable|Size|Size till the end of object|

h4. Header

|variable|Size|Size till the end of header|

|variable|Size|Size of N-th key|
|variable|Data|N-th Key|
|variable|Integer|N-th Value offset from beginning of body|
||This section repeats|

h4. Body

|variable|RBSON|N-th value|
|||This section repeats|

h4. Number

|1 b|0x03|Type|
|variable|Size|Size till the end of number|
|1 bit||Negative|
|7 bits||Reserved|
|variable|Natural|numerator|
|variable|Natural|denominator|

h3. One-byte types

These types consist of single type byte, here's their codes:

|0x05|Nil|
|0x06|True|
|0x07|False|

By Iaroslav Gridin on 2017-01-13 18:00:31 +0200 Powered by bitcheese wiki engine