preloader

JSON vs BSON

illustrations illustrations illustrations illustrations illustrations illustrations illustrations
JSON vs BSON

Published on Jan 12, 2021 by Harsh Gupta

What is JSON?

JSON is JavaScript Object Notation. It is a light-weight data interchange format, which can get transferred from one system to the other easily. It is easy to read and write this format. It is also not a complex task for machines to parse and generate. The text format is completely language independent.

At high level, JSON will have two things- An object and an array. An object is a collection of name/value pairs and an array is an ordered list of values.With the combination of two, you can have a complete JSON structure. The maximum amount of documents that one can embed in a document is 100. This is a very important factor while working with MongoDB.

So an object will start with curly braces and end with curly braces and then comes the key and value. An array will start with the normal, non-curly brackets, then comes value and comma. There are data types that can be supported. See the image below to understand it better.

What is BSON?

BSON is nothing but Binary JSON i.e Binary JavaScript Object Notation. Unlike JSON, it is not in a readable format. It supports the embedding of documents and arrays within other documents and arrays. Like JSON, it is easy for machines to parse and generate. For more information on both these topics, you can always get an insight from various sources. When you check the websites for information, you will see the difference in JSON and BSON and understand how different the two are in terms of readability.