JSON vs BSON

JavaScript Object Notation (JSON) is a standard file format that uses human type readable text to transmit data with attribute-value pairs and array data types. This is one of the most common data formats which are mainly used for asynchronous browser-server communication. JSON is a language-independent format. BSON, on the other hand, is a computer interchange format that is mainly used for data storage and as a network transfer format in the MongoDB database. It is a simple binary form which is used to represent data structures and associative arrays (often called documents or objects in MongoDB).

Let us study much more about JSON and BSON in detail:

  • BSON stands for binary JSON which consists of a list of ordered elements containing a field name, type, and value. Field name types are typically a string. The fundamental of it includes JavaScript and there are many programming languages today which makes use of the code to generate and parse the JSON format related data.
  • The BSON type supports the dates and binary data and because of its nature, this is not in a readable form whereas normal JSON files consist of a key-value pair. It is not a mandate that the BSON files are always smaller than JSON files but it surely skips the records which are irrelevant while in case of JSON you need to parse each byte. This is the main reason for using it inside MongoDB.
  • The BSON type format is lightweight, highly traversable and fast in nature. BSON implementation is used for supporting embedding objects and arrays within other objects. Inside BSON objects indexes can be built and the objects are matched against query expressions on the top level and BSON keys. BSON is that binary encoding JSON document which is used to store documents in collections. Support for data types like binary and date which aren’t supported in JSON are added into BSON.
  • In practicality, much information about BSON is not needed. Using only the native types of the language and the supplied types such as the ObjectID of the driver is needed and the mapping will be done on its own to the BSON type.

Post a Comment

0 Comments