V24s

"Get Updates : Subscribe to our e-mail newsletter to receive updates........" "Good Luck frnds" Admission 2019 Application Form 2019 Colleges Entrance Exam 2019 Results 2019 Notification 2019 University Educational Jobs 2019 Government Jobs 2019

Search This Blog v24s guys

03 April, 2013

jQuery Read and Parse JSON String using ParseJSON Method

Introduction
   
Here I will explain how to read and Parse 
JSON string in jQuery using ParseJSON method in JavaScript,asp.net and get string value from JSON string in jQuery.

Description: 
   
In previous posts I explained 
jQuery Get number of facebook likes, shares count for url, jQuery Google Currency Converter API Example, jQuery Highlight gridview rows on mouseover, jQuery Change style of controls, Show multiple months in datepicker, and many articles relating to jQuery, modal popup, asp.net. Now I will explain how to read and Parse JSON string in jQuery using ParseJSON method in JavaScript,asp.net.

To implement this functionality we need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Read and Parse Data using ParseJSON method</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
var name = '';
var jsonstr = '[{"UserName":"Suresh","UserID":"1"},{"UserName":"Aspdotnet","UserID":"2"}]';
var obj = $.parseJSON(jsonstr);
$.each(obj, function() {
name += this['UserName'] + "<br/>";
});
$('#divjson').html(name); ;
})
</script>
</head>
<body>
<div id="divjson">
</div>
</body>
</html>
In above code we used parseJSON method to read formatted JSON string

Demo

Once we run above code we will get output like as shown below

Suresh
Aspdotnet

No comments:

Popular Posts

Recent Posts

Google Analytics