json学习笔记
JSON:JavaScript 对象表示法(JavaScript Object Notation)。
JSON 是存储和交换文本信息的语法。类似 XML。
JSON 比 XML 更小、更快,更易解析。
实例:
View Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="json_test.aspx.cs" Inherits="Web_SoftAceTest.json.json_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var text = '{employees:[' +
'{"LastName":"Getes","FirstName":"Bill"},' +
'{"LastName":"Yue","FirstName":"Ace"},' +
'{"LastName":"Bush","FirstName":"George"}]}';
var obj = eval("(" + text + ")");
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
Name:<span id="sp_name"></span><br />
Age:<span id="sp_age"></span><br />
Address:<span id="sp_address"></span><br />
Phone:<span id="sp_phone"></span>
</p>
<script type="text/javascript">
var JsonObject = { employees: [
{ "Name": "AceYue",
"Age": "22",
"Address": "Guangdong Shenzheng",
"Phone": "1234567"
},
{
"Name": "Getes",
"Age": "52",
"Address": "Americ",
"Phone": "555-1234567"
相关新闻>>
- 发表评论
-
- 最新评论 更多>>