<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> function clone(myObj) { if (typeof (myObj) != 'object') return myObj; if (myObj == null) return myObj; var myNewObj = new Object; for (var i in myObj) myNewObj[i] = clone(myObj[i]); return myNewObj; } function test() { var data = { Id: 1, Text: "lin" }; var dataCopy = {}; dataCopy = clone(data); var strDataCopy = JSON.stringify(dataCopy); alert(strDataCopy); } </script> </head> <body> <form id="form1" runat="server"> <div> <button onclick="test()">测试</button> </div> </form> </body> </html>