BSON : Binary JSON

Category: Programming
4,558 views

BSON stands for Binary JSON.

What is the Full Form of BSON?

BSON stands for Binary JSON.

What is BSON?

BSON stands for binary JSON (It is a superset of the JSON data with some more data types in it and most importantly it is a binary byte array). It is also used as a serialization format used in MongoDB.

Advantage of BSON:

  • BSON way better underpins dates and binary data.
  • BSON records tend to be littler than JSON records, which is the most reason for utilizing its interior MongoDB.
  • The BSON sort arrangement is exceedingly traversable and quick in nature. Interior BSON objects file can be built and the objects are coordinated against inquiry expressions on the beat level and BSON keys.
  • Using it was the local sorts of the dialect and the provided sorts such as the ObjectID are all that’s required for the mapping to be done to the BSON sort.

BSON Example:

A document such as {"hello":"world"} will be stored as:

Bson:
  \x16\x00\x00\x00               // total document size
  \x02                           // 0x02 = type String
  hello\x00                      // field name
  \x06\x00\x00\x00world\x00      // field value (size of value, value, null terminator)
  \x00                           // 0x00 = type EOO ('end of object')