JSON vs BSON
Before knowing the differences between the JSON and BSON, we should know about JSON and BSON separately.
What is JSON?
The data types supported by JSON are string, number, object, array, true, false, and null.
In the above JSON example, "id" is defined. The name of the id starts with a '_' underscore character. It is mandatory to provide the 'id' to the json document. If we do not provide the 'id' to the json document, the system id is created. In the above, subject is an array that contains the values Maths, English, and Hindi. An address is a object as address contains the çurly bracket.
The '_id' is a 12 bytes hexadecimal number that provides the uniqueness of every document. We can add the '_id' field in a json document. If we do not provide the '_id' field in a json document, then the system itself generates the '_id'.
These 12 bytes are divided into four sections:
What is BSON?
It supports the adding of documents and arrays within other documents and arrays.
BSON has following three characteristics:
Differences between JSON and BSON.
The following are the differences between JSON and BSON: