JSON format

Consider the following table:

Firstname

Lastname

Information

John

15

Subject: History, Grade B

Jack

18

Subject: Physics, Grade A

Jill

17

Subject: Physics, Grade A+

 

The Information field contains a column containing multiple values categorized under Subject and Grade. Such columns that contain multiple data are also known as columns with nested data.

Portability has been an important aspect of transferring data from one system to another. In general, ODBC connectors are used to transfer data between database systems. Another common format is CSV files with the data represented as comma-separated values. CSV files are optimal for structured data that doesn't contain more complex data structures such as nested values. In such cases, JSON provides an optimal and structured way to capture and preserve information using a key-value pair syntax.

In JSON representation, the table can be defined as follows:

( 
   { 
      "Firstname":"John", 
      "Age":15, 
      "Information":{ 
         "Subject":"History", 
         "Grade":"B" 
      } 
   }, 
   { 
      "Firstname":"Jack", 
      "Age":18, 
      "Information":{ 
         "Subject":"Physics", 
         "Grade":"A" 
      } 
   }, 
   { 
      "Firstname":"Jill", 
      "Age":17, 
      "Information":{ 
         "Subject":"Physics", 
         "Grade":"A+" 
      } 
   } 
) 

Notice that the Information key contains two keys, Subject and Grade, with each having a corresponding value.

Today, most product developers and vendors accommodate the ingestion of JSON-formatted data. Also, due to the simple manner in which complex relationships can be expressed as well as exchanged in text format, JSON has become immensely popular across the world in the developer community.

MongoDB captures data in JSON format. It internally stores them in BSON—an optimized binary representation of the JSON data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.244.250