Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> JSON >> Introduction to JSON
Introduction to JSON

JSON is smaller than XML, and faster and easier to parse. JSON (an acronym for JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associ
Views: 877     Comments: 0
by Arun Singh on 5/4/2012

Introduction to JSON

JSON is smaller than XML, and faster and easier to parse. JSON (an acronym for JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. JSON is syntax for storing and exchanging text information.

JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

JSON is built on two structures:

·         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.

·         An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

JSON is not only a syndication format (e.g. an alternative to XML); it is a language-independent data interchange format.

Why JSON?

For AJAX applications, JSON is faster and easier than XML.

Using XML:

·         Fetch an XML document

·         Use the XML DOM to loop through the document

·         Extract values and store in variables

Using JSON:

·         Fetch a JSON string

·         eval() the JSON string

JSON Syntax Rule:

JSON syntax is a subset of the JavaScript object notation syntax.

·         Data is in name/value pairs

·         Data is separated by comma

·         Curly brackets holds objects

·         Square brackets holds arrays

Example: In this example, simply I have created JSON object and store some values after then set these values into proper names.

<html>

<head>

                <title>JSON Object Creation Demo</title>

</head>

<body>

<h2>JSON Object Creation in JavaScript</h2>

<p>

Name: <span id="jname"></span><br />

Age: <span id="jage"></span><br />

Address: <span id="jstreet"></span><br />

Phone: <span id="jphone"></span><br />

</p>

<script type="text/javascript">

                      var JsonObject= {

                                                                "name":    "Arun Kumar Singh",

                                                                "street":    "Kothapaarcha",

                                                                "age":   22,

                                                                "phone":  "000 1234567"

                                                };

                                                document.getElementById("jname").innerHTML=JsonObject.name

                                                document.getElementById("jage").innerHTML=JsonObject.age

                                                document.getElementById("jstreet").innerHTML=JsonObject.street

                                                document.getElementById("jphone").innerHTML=JsonObject.phone

                </script>

</body>

</html>

 Now save this file in html format and open it with web browser.

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by Arun SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 2679
  
Copyright © 2013MindStick. All Rights Reserved.