Subscribe For Free Updates!

We'll not spam mate! We promise.

Sep 2, 2012

What is Json: Access JSON using Java Script


What is Json , Access JSON using Java Script
To day I will Explain What is Json, Basic  Introduction of JSON  and  Accessing JSON using Java Script.
JSON is very Important for smart phone Online Application Development .
So Before Developing any Smart phone Application we Utilize or before using Any Web service we must have an idea about Json.

So Lets Start with Json Abbreviation.
JSON (JavaScript Object Notation) is a lightweight , text-based open standard
 format for exchanging objects ,
designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. 
Reason For Using Json
 1) Json is language-independent, Json parsers available for many languages.
 2)  JSON is used for data interchange between programs.Although JSON does not use a description language, and so technically does not qualify as a SOA protocol.
 3)  IT is designed to be both easily human — and machine — readable. It is an alternative to XML that is more concise because, unlike XML, it is not a markup language that requires open and close Tags.
4)  It has been gaining a lot of attention lately as a lightweight alternative to XML, especially in Ajax applications. Why is this? Because of the ability in JavaScript to parse information quickly using the eval( ) function. JSON does not require JavaScript, however, and you can use it as a simple exchange format for any scripting language

Understanding Json Format :
Below is Json Format :
"Students": [
{ "Name": "Sajjad Ashraf",
"Major": "Programming"
"Name": "Hammad Anwer",
"Major": "Oracle Data Base"
"Name": "Zeeshan Ejaz",
"Major": "Computer Hardware"
The above example shows A table Name "Students"  showing information about three students - their name and major subjects that are stored using JSON.

Though you need to read and understand JSON structures to understand the concept of JSON better, the following image may help you to understand the concept of JSON .

What is Json , Access JSON using Java Script

JSON is built on two structures:

1.   A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
2.  An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

The Algo below show some other examples of JSON:

What is Json , Access JSON using Java Script

What is Json , Access JSON using Java Script

What is Json , Access JSON using Java Script

Sample Code for Using Json in JavaScript : Code is Below :
<!DOCTYPE html>
<h2>JSON Object Creation in JavaScript By </h2>
Name: <span id="jname"></span><br />  
Age: <span id="jage"></span><br /> 
Address: <span id="jstreet"></span><br /> 
Phone: <span id="jphone"></span><br /> 

var JSONObject = {

Copy above code in Text file or notepad and save as .html extension.
OUT Put in Following image:

Json JavaScript

History of JSON
-Json was invented by  Douglas Crockford  in 2001.
-In 2005, Yahoo started using JSON in it's web services.
-In later 2006, Google started offering JSON in it's Gdata web protocol.
-Today, JSON is one of the most widely used data-interchange format in web, and supported by most of the Web APIs (like twitter api) to fetch public data and creating applications out of them.
-Various Web Services and APIs use JSON format to provide public data. Using the associated Service / API, you can fetch that data and use it to create applications.
In Next Post I will Show how to return JSON Data instead of XML From Soap Service.So Keep Reading .

If You have any problems or need help Make Sure You Comment! Peace Out!

Plese Feel Free to Socializer This Post


Become a Fan

visual studio learn