Share & learn

Through Innovative Digital Library

What is JSON and BSON?

Explain about JSON and BSON. Which one is better JSON or BSON?


Posted by Nikheel on January 2nd 2018 13:56 PM

JSON (Java Script Object Notation) : JSON is an open standard whose main purpose is to exchange data over the web. JSON is in human readable format. JSON uses JavaScript derived syntax for representation of data in human readable format. JSON supports various data structures like arrays and objects. Because of this reason, it becomes very easy to read and data from JSON. JSON is also language independent. The JSON filename has an extension as .json. Where JSON can be used? - Mainly JSON is used while building applications which are based on JavaScript having browser extensions and websites. - We can also use it while serializing structured data and transmitting it over network. - The most important task that JSON does is that of transmission of data between a server and web application. - Web services and APIs use JSON format to provide public data. This example shows how to use JSON to store information regarding novels, based on their name, edition ,etc. Example : An JSON object is a set of key-value pairs which starts with "{" and ends with "}". Lists are one or more values surrounded by [] and separated by ",". { "novel": [ { "id":"101", "name": "AAA", "edition": "first", "author": "John Smith" }, { "id":"107", "name": "BBB, "edition": "second", "author": "E. Jamesworth" } ] } Let's use this JSON with Java Script. Here we will have two objects stored as object1 and object2 out of which we will fetch necessary details of object2 and put it on webpage. Create a file named as test.html and copy following code to it. Once it is saved, run it on any Javascript enabled browser. Output will be as shown in image.

title>JSON example</title>
script language "javascript" >
object1 = { "name" "AAA""author"  "John Smith" };
document.write("<h1>JSON Example</h1>");
document.write("<h3>name = ""</h3>");  
document.write("<h3>Author = ""</h3>");   

object2 = { "name" "BBB""author"  "E. Jamesworth" };
document.write("<h3>name = ""</h3>");  
document.write("<h3>Author = ""</h3>");   
document.write("<hr />");
document.write( " is a good novel to read " ", written by ";
document.write("<hr />");

Posted by Nikheel on January 2nd 2018 13:58 PM

BSON : (Binary JSON) - BSON is basically Binary JavaScript Object Notation. The difference between JSON and BSON is that, BSON isn't in human readable format. - Both JSON, BSON support the embedding of documents and arrays within other documents and arrays. - A single entity from a BSON is called as a 'document'. A document is made of zero or more key-value pairs but in binary format. - MongoDB stores data in BSON format. - It is easy for machines to parse and generate data using BSON. - Like JSON, BSON is also language independent. - The BSON filename has an extension as .bson. Following data types are supported by BSON. e.g. byte, int, double Main characteristics of BSON : 1. Lightweight : BSON is lightweight. Keeping spatial overhead to a base is imperative for any information illustrative arrangement, particularly when utilized over the system. 2. Traversable : BSON is easily traversable. Main purpose of creating BSON was to make traversing fast. 3. Efficient : As almost every language supports basic C data types, it is possible to quickly encode and decode data from BSON. Comparing JSON and BSON : - When it comes to comparing BSON and JSON, BSON has some extra additional features as compared to JSON, like length prefixes. - This is the only reason that BSON needs less space. - If we talk about encoding and decoding BSON is faster than JSON.

Posted by anonymous on June 30th 2020 02:40 AM

Levitra Prix Baisse [url=]Cialis[/url] The Canadian Medstore buy cialis online uk Online Drug Store Hk

Levitra Prix Baisse  [url=]Cialis[/url] The Canadian Medstore  <a href=>buy cialis online uk</a> Online Drug Store Hk

Posted by anonymous on July 16th 2020 20:18 PM

levitra 10 mg con alcohol Kayasydaybum [url=]cialis 5 mg best price usa[/url] gakbocky cialis tadalafil beter dan viagra Braima cialis online Chepverb generico viagranow eu

levitra 10 mg con alcohol  Kayasydaybum [url=]cialis 5 mg best price usa[/url] gakbocky cialis tadalafil beter dan viagra  Braima <a href=>cialis online</a> Chepverb generico viagranow eu

Posted by anonymous on August 7th 2020 17:12 PM

viagra falls band south bend indiana viagra 100mg buy cheap health insurance medical specialties medicine search online cobb county health department find medical doctor best doctors list

viagra falls band south bend indiana <a href="">viagra 100mg</a
buy cheap health insurance medical specialties 
medicine search online cobb county health department 
find medical doctor best doctors 
Answer Question

Your email address will not be published. Required fields are marked *

  • Minimum 20 character

related questions

Most liked questions

Most answered questions

ZF2I Refresh
ZF2I Refresh
Forgot password
Ask a Question
Minimum 20 character
Minimum 20 character
Minimum 20 character
ZF2I Refresh