Article
    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
    API(s)
    Sencha-Touch
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

Home >> JSON >> Parsing a Message in JavaScript using JSON
Parsing a Message in JavaScript using JSON
Parsing a Message in JavaScript using JSON


by Arun Singh on 5/8/2012 5:15:27 PM

Views: 1829       Comments: 0

Parsing a Message in JavaScript using JSON

This article is going to explain on how to parse a message in JavaScript using JSON. We can parse the message with JSON in JavaScript by using the method String.parseJSON(filter).  It parses the JSON message to a string or object. The parameter filter is optional in this method which is used to filter message or transform their results. This method internally uses the JavaScript's method eval() to parse messages.

To understand the Message Parsing in JavaScript using JSON writes down the following line of code.

<html>

<head>

<title>

JSON Message Parsing With Example

</title>

<script language="javascript" src="json2.js"></script>

<script language="javascript" >

                var StudentsDetails = {

            ////Decalration of array to collect record of Student.

                   // Information of MCA students

                        "MCAStudent": [{

                         "StudentName": "Kumar Vishu",

                         "Roll_No":100,

                         "Stream": "Computer Science",

                         "Course": "MCA"

                    },

                       {

                         "StudentName": "Tarun Bindra",

                         "Roll_No":101,

                         "Stream": "Science",

                         "Course": "B.Tech"

                    }

            ]

               

                }

                                // Printing all array values

                    var i=0

                    var dataCollection = new Array();

                    for(i=0;i<StudentsDetails.MCAStudent.length;i++)

                    {         

                        // Push the data into array

                            dataCollection.push(StudentsDetails.MCAStudent[i].StudentName);

                            dataCollection.push(StudentsDetails.MCAStudent[i].Roll_No);

                            dataCollection.push(StudentsDetails.MCAStudent[i].Stream);

                            dataCollection.push(StudentsDetails.MCAStudent[i].Course);

                    }                                         

                         

                           alert("Welcome to JSON Message Example ");

                           // Use toJSONString() function for message parsing

                           alert(dataCollection.toJSONString());

</script>

</head>

<body>

Message parsing successfully in JavaScript using JSON.

</body>

</html>

Now save the above code in html format (Here I’m saving this file with ‘JSONParsing.html’ ) and execute with web browser.

Parsing a Message in JavaScript using JSON

Now click on button ‘Ok’ after that parsed message will be display in alert message box.

Parsing a Message in JavaScript using JSON

Highlighted area; showing the parse message in alert message box. Now click on button ‘Ok’.

Parsing a Message in JavaScript using JSON

This is the complete description on Parsing a Message in JavaScript using JSON.

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Arun SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 7375
Advertisement
MindStick SurveyManager
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.