<head runat="server">
<title></title>
<script language="javascript" type="text/javascript" src="Scripts/jquery-1.6.2.js"></script>
<script language="javascript" type="text/javascript" src="Scripts/json2.js"></script>
</head>
var EmployeeSerialized = JSON.stringify(GetInput()); //Convert object to JSON string
**var myobj = jQuery.parseJSON(EmployeeSerialized); //Use jQuery lib to translate JSON to Javascript object**
var myobj2 = JSON.parse(EmployeeSerialized); //alternative way: Use Json2.js lib to translate JSON to Javascript object
function GetInput()
{
var emp = new Object();
emp.Name = 'Brij';
emp.Age = '27';
return emp;
}
在不使用JSON2.js库的情况下将Javascript对象转换为JSON的jQuery方法是什么?
答案 0 :(得分:2)
简单回答:抱歉,jQuery不支持编码为JSON,您必须使用本机浏览器支持或json2.js