Skip to main content

JSON Tutorials : Getting Started


JSON is widely accepted text formatted structured data. JSON stands for "JavaScript Object Notation". In general JSON can represent 1. Object of database record. 2. Object to represent a list of HTML elements. 3. Result of search query. 4. Response of an Ajax call. Here you can see JSON is used in many different areas and for many different scenarios. This means it has simple data structure. most of programming languages adopt it and it can flow easily from one connection to another. You can find JSON office definition here JSON Official Site. JSON is represented by two structural types, which includes two primitive types. Structural types

Array: A sequential list of primitive data types between square brackets [ ]
Object: Collection of key, value pair stored inside curly braces { }, where value would be primitive data type

Primitive types:
There are two primitive types key and value. "key" should be string and "value (data type)" could be anything like integer, string , Boolean , empty or null. Lets see some example of JSON objects.

Array :

[
    "apple",
    "orange",
    "blackberry",
    "grape"
]
Object:

{
    "username": "zainabed",
    "first_name": "Zainul",
    "country": "India"
}


Mix Object:

{
    "username": "zainabed",
    "first_name": "Zainul",
    "country": "India",
    "hobby": [
        "reading",
        "programming",
        "sports"
    ]
}


JSON is widely accepted and used because
  • It is lightweight, that is why it is possible to transfer large set of data without exhausting internet bandwidth.
  • It is language independent, which means most of the programing languages have mechanism to accept or generate JSON objects, it doesn’t need extra functionality to make JSON objects compatible with other languages.
  • JSON can be as primary object for database system. it is used to store and read or perform CRUD operation on JSON which can be stored as documents. MongoDB is popular database system which based on JSON documents.
  • JSON can have Embedded documents as well, it helps to avoid expensive join operations on related documents. here rather using joins, one JSON documents can be embedded inside another.
  • JSON object can be used to represent HTML entities like list of user, tables or image gallery. AngularJs is most powerful tool to transform JSON to HTML.
  • JSON can also represent search result. search result could include search count, search title and description list , etc. all this can be included in a JSON object. Elasticsearch represent its search result in JSON object. as it is JSON object it can be used in any programming languages as result.
  • JSON play important role in drawing of charts. charts requires data set to create a particular chart and JSON object is perfect data model for it. D3 charts are always use JSON objects.
Frequently Asked Questions:

1: Can JSON starts with Array?
Answer: Yes, JSON can start with Array or Object, there is no such restriction.

2: What is the correct JSON content type for HTTP response?
Answer: Correct content type for JSON is application/json

3: Safely turning a JSON string into an object inside a JavaScript?
Answer: Following two function call will turn string to JSON object


jQuery.parseJSON( jsonString ); //Jquery

JSON.parse(jsonString); //plain JavaScript

Comments

Popular posts from this blog

AngularJs Tutorial: Getting Started

This tutorial will help you to create a dynamic web application using power of AngularJs. ·   What is AngularJs AngularJs is javascript MVC framework (maintained by Google) which molds static HTML application to dynamic web application. That was a brief introduction, you can find more information on Wiki and AngularJS Site . AngularJs follows MVC pattern to separate out model from view and manage it by controller. See this image Goal of using AngularJs is to convert static HTML template to dynamic (Angular) template.   ·   How to convert static template to dynamic (Angular) Template Now consider the following static HTML template which contain list of movies title. <html> <head></head> <body>   <h1>Upcoming Movies</h1> <ul>     <li>       <span>Godzilla</span>     </li> <li>       <span>Batman vs Superman</span>     </li> <li>       <span>Sta

AngularJs Tutorials : Bootstrap

Every application starts with bootstrap process which initialize application and wire it other with dependencies and configurations. AngularJs is not different from other application. It also starts application with bootstrap process. Following operation happens inside AngularJs bootstrap process. Load application module. Create dependency injector and load dependencies. Compile HTML and create scope for application. All these steps happens inside angular.js scripting file. therefore we need to include it first. we can include it inside HEAD tag or at end of BODY tag. Note: Adding angular.js file at end of body tag will allow browser to load of HTML elements without any delay and afterwards load angular.js and begin bootstrapping process. You can get angular.js source file from https://code.angularjs.org/ <script src= ”https://code.angularjs.org/1.3.0/angular.js” type= ”text/javascript” > AngularJs bootstrap process happens on docum

How to create SSH Key for GitHub and Bitbucket

This  post  demonstrate how to  generate  SSH private and  public   key  with fundamental steps and  assist   you  to  add   public   key  inside your  GitHub  and Bitbucket account. But first why we  need  this SSH  public   key ? Whether you are working in the team or an individual and you want make any operations on secure GIT repository like clone or push your latest changes then you require to provide your credentials to help GIT to authenticate you and approve those operations. But when  you  do so,  you  are  asked  to  provide  your username &  password ,  each   time  on  each   operation . It looks  simple  earlier, but later  becomes  a  headache . SSH  connection   helps   us  to  authenticate  using public and private keys, that  we  generate only once, later  we  don’t need to  authenticate ,  SSH  will  do  this behalf of  us . But how does it  work ? SSH   authenticate  you  using  an  identity , your  identity  and this  identity   comprise   combination  of p