Page: [root]/code/rbson | src | log | faq | css

RBSON format specification

Size

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

3 bData
1 bitIf it's 1, there's one more chunk after that one
7 bitUnused
This section repeats

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

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.

variableSize
variableData

Array

Intro

1 b0x04Type
variableSizeSize till the end of array
variableSizeSize till the end of header
variableIntegerOffset from start of Body section to start of N-th array element, repeats

Body

variableRBSONN-th Array entry, repeats

Data

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

1 b0x01Type
variableSizeSize of bytestring
variableDataBytestring

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.

Intro

1 b0x02Type
variableSizeSize till the end of object

Header

variableSizeSize till the end of header
variableSizeSize of N-th key
variableDataN-th Key
variableIntegerN-th Value offset from beginning of body
This section repeats

Body

variableRBSONN-th value
This section repeats

Number

1 b0x03Type
variableSizeSize till the end of number
1 bitNegative
7 bitsReserved
variableNaturalnumerator
variableNaturaldenominator

One-byte types

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

0x05Nil
0x06True
0x07False

Last edited: Iaroslav Gridin on 2017-01-13 16:07:23 +0000