JSON Object in JavaScript example



User Rating:  / 4
PoorBest 
Details
Category: JSON
Created on Wednesday, 25 July 2012 08:23
Last Updated on Wednesday, 25 July 2012 08:23
Published on Wednesday, 25 July 2012 08:23
Written by Administrator
Hits: 6145

the following code creates JSON Object in JavaScript : 

View source
<!DOCTYPE html>
<html>
<body>
<h2>www.developerpages.gr</h2>
<h2>JSON Object in JavaScript example </h2>
 
<p>
First Name: <span id="firstname"></span><br />  
Last Name: <span id="lastname"></span><br />  
</p>  
 
<script type="text/javascript">
var JSONObject = {
  "jfname":"Test Firstname",
  "jlname":"Test LastName"};
 
 document.getElementById("firstname").innerHTML=JSONObject.jfname  
 document.getElementById("lastname").innerHTML=JSONObject.jlname  
 
</script>
 
</body>
</html>