What is BSON? BSON features? BSON Data Types? BSON Helpful Tools?


What is BSON? BSON features? BSON Data Types? BSON Helpful Tools?

What is BSON?

BSON is a short form of “Binary JSON”. Its combination of “B” From “Binary” and “SON” from “JSON” =BSON. It’s a Binary-encode serialization of JSON Document. It is a data interchange format mainly famous for data storage and transfer format in the MongoDB database.  It is a binary form of objects and data structures.

BSON supports embedding documents, array, and objects with in other documents. Means one objects can have more objects. BSON is also designed to be fast to encode and decode.
BSON strong type and it support more Data Types then JSON. BSON element consists of a fields name, type and value. Fields names are strings.

BSON is designed for storage space and high speed scanning. Large elements in a BSON document are prefixed with a length field to facilitate scanning. In some cases, BSON will use more space than JSON due to the length prefixes and explicit array indices.

Example

JSON
BSON
Description


{"hello": "bson"}

\x16\x00\x00\x00    
\x02
hello\x00  
\x06\x00\x00\x00bson\x00
\x00                                               
total document size
0x02 = type String
field name
field value
0x00 = type EOO ('end of object')


 BSON main features:


Lightweight – Its design for minimum important for any data representation format, especially when used over the net­work.
Traversable - BSON is designed to be traversed easily.
Efficient – Due to C data types it’s very fast in Encoding data to BSON and decoding from BSON.

BSON Data types


string

integer (32- or 64-bit)

double (64-bit IEEE 754 floating point number)

date (integer number of milliseconds since the Unix epoch)

byte array (binary data)

boolean (true and false)

null

BSON object

BSON array

BSON Helpful Tools


https://github.com/dwight/bsontools

Previous
Next Post »
Thanks for your comment