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.




JSON Message Parsing With Example


<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",


                         "Stream": "Computer Science",

                         "Course": "MCA"



                         "StudentName": "Tarun Bindra",


                         "Stream": "Science",

                         "Course": "B.Tech"





                                // Printing all array values

                    var i=0

                    var dataCollection = new Array();



                        // Push the data into array







                           alert("Welcome to JSON Message Example ");

                           // Use toJSONString() function for message parsing





Message parsing successfully in JavaScript using JSON.



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.

  Modified On Sep-07-2019 12:13:25 AM

Leave Comment