Diff: [root] @ af543b0d0d2 | faq | css

rbson from ancient archives

File created: code/rbson [Diff]

-- /dev/null++ b/code/rbson
@@ -1 +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.


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|

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|

h3. One-byte types

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


By Iaroslav Gridin on 2017-01-13 16:00:31 +0000