javascript基础(json数据操作)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>jsdata</title>
	<script type="text/javascript">
	  var object={
                 id:45454,
                country:'中国',
	             hobby:{
                    first:'swimming',
                    second:'fishing',
                    third:'games'
	               }
	          }
	    function testjs(){
			      console.log(object.hobby.first);
				  console.log(object.country);
		          for(var index in object.hobby){
			         console.log(object.hobby[index]);
				  }
				 }
	</script>
</head>
<body>
<input type="button" onclick="javascript:testjs()"  value="getdata" />
</body>
</html>

你可能感兴趣的:(javascript基础(json数据操作))