json初识

来源:互联网 发布:linux c 创建文件夹 编辑:程序博客网 时间:2024/05/29 16:12
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>My JSP 'MyJson.jsp' starting page</title></head><body><span id="span1"></span><br></body><script type="text/javascript">var json = {id : 1,name : "ss",age : 25};var jsonArray = [ {id : 1,name : "ss",age : 25}, {id : 2,name : "saa",age : 25}, {id : 3,name : "dd",age : 25} ];var p = {id : 1,name : "qq",home : [ "上海", "杭州", "北京" ]};var p2 = {id : 1,name : "ass",isLove : false,home : [ "广州", "深圳" ],show : function() {alert("yes");}};var eleSpan = document.getElementById("span1");eleSpan.innerHTML = json.id + " , " + json.name + " , " + json.age+ "<br/>";for ( var i = 0; i < jsonArray.length; i++) {window.document.write(jsonArray[i].id + " , " + jsonArray[i].name+ " , " + jsonArray[i].age + "<br/>");}for ( var j = 0; j < p.home.length; j++) {window.document.write(p.home[j] + " , ");}//document.write(p2.isLove ? "已婚":"单身");p2.show();</script></html>

原创粉丝点击