FAQ

What is the point of BSON when it is no smaller than JSON in many cases?

BSON is designed to be efficient in space, but in many cases is not much more efficient than JSON. In some cases BSON uses even more space than JSON. The reason for this is another of the BSON design goals: traversability. BSON adds some "extra" information to documents, like length prefixes, that make it easy and fast to traverse.

BSON is also designed to be fast to encode and decode. For example, integers are stored as 32 (or 64) bit integers, so they don't need to be parsed to and from text. This uses more space than JSON for small integers, but is much faster to parse.

Where can I get more help/infomation?

The best place to ask questions about BSON is on the BSON mailing list.

How can I contribute or make fixes to this site?

The best way to contribute to this site is to fork the project and send us a pull request.

Examples

The following are some example documents (in JavaScript / Python style syntax) and their corresponding BSON representations.

{"hello": "world"} "\x16\x00\x00\x00\x02hello\x00
 \x06\x00\x00\x00world\x00\x00"
{"BSON": ["awesome", 5.05, 1986]} "\x31\x00\x00\x00\x04BSON\x00\x26\x00
 \x00\x00
\x020\x00\x08\x00\x00
 \x00awesome\x00
\x011\x00\x33\x33\x33\x33\x33\x33
 \x14\x40
\x102\x00\xc2\x07\x00\x00
 \x00\x00"