JSON versus BSON
By now, we know JSON very well. Let's learn about BSON with three simple points:
- MongoDB drivers convert the incoming JSON to binary-encoded JSON called BSON and pass it to the storage engine, currently WiredTiger. Let us visualize it as follows:
In the preceding diagram, the incoming JSON is converted to a binary-serialized JSON-like entity called a BSON Document and then stored in DB.
- The specifications of BSON provide various benefits, such as it has a small memory print as compared to JSON, it is traversable, and it can be queried as well as quickly parsed for any other language support
- When the BSON document is retrieved, the data types in BSON specs are converted to type native language data type by mongoDB drivers, which are in turn used by the developer
The developer has nothing to do with BSON directly, they will be working with JSON. It is the MongoDB driver that handles everything.
Note
For more info on BSON, you can follow this link:Â http://bsonspec.org/.