JSON vs BSON
What is JSON?
The data types supported by JSON are string, number, object, array, true, false, and null.
What is BSON?
It supports the adding of documents and arrays within other documents and arrays.
BSON has following three characteristics:
- Lightweight: When used over the network, the JSON keeps the overhead involved in processing extra header data to a minimum.
- Traversable: It is designed to traverse easily across the network. This helps in its role as the primary data representation for MongoDB.
- Efficient: It allows C data types that allow easy and quick encoding and decoding of data.
JSON vs BSON
The following are the differences between JSON and BSON:
|It is a standard file format type.||It is a binary file format type.|
|JSON contains some basic data types like string, numbers, Boolean, null.||BSON contains some additional data types like date, timestamp, etc.|
|Databases like AnyDB, redis, etc. stores the data into the JSON format.||The data in MongoDB is stored in a BSON format.|
|JSON requires less space as compared to BSON.||BSON requires more space as compared to JSON.|
|It is comparatively less faster than BSON.||It is faster as compared to BSON.|
|It is used for the transmission of data.||It is used for the storage of data.|
|It does not have encoding and decoding technique.||It has faster encoding and decoding technique.|
|If we want to read any particular information from the JSON file then it needs to go through whole content.||In BSON, indexes concept is used that skips all the content which are not in use.|
|JSON format does not require to be parsed as it is already human readable.||It requires to be parsed as it can be easily parsed by the machines.|
|JSON is a combination of objects and arrays where an object is a collection of key-value pairs while array is an ordered list of elements.||The binary encoding technique provides some additional information such as length of the string and object subtypes. BinData and Date are the additional data types supported by BSON over the JSON.|