Using JSON.parse() method you can parse a JSON . JSON creates JavaScript objects ,using
JavaScript to parse the data is easy and
mostly used by developers. If you are using PHP as your major language you can
also use JSONencode() and JSONdecode() to parse a JSON string/object. Similarly
according to language used JSON parsing differs and JSON can be used and parse.
Example:
<!DOCTYPE html>
<html>
<head>
<title>JSON Tutorials</title>
</head>
<body>
<h1>An Example of JSON Parse</h1>
<scriptsrc="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<h2>Please Visit</h2>
<div id = "id1"></div>
<script type="text/javascript">
varobj = $.parseJSON( '{ "Course": "JSON","URL":"http://nirajanghimireyworkshop.blogspot.com/search/label/json" }' );
alert( "Do you like "+obj.Course+" ?");
document.getElementById("id1").innerHTML = "<a href = "+obj.URL+" /> "+obj.Course+" </a>"
</script>
</body>
</html>
No comments:
Post a Comment