未捕获的SyntaxError:尝试解析JSON字符串时意外的令牌e
我尝试使用JSON.parse返回下面的字符串的JavaScript对象。 但是,我收到“未捕获的SyntaxError:意外的令牌e”。
{
"__type": "HRIS.oHRData, HRIES, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"TPDDListValue": new Ajax.Web.DataSet([]),
"DPDDListValue": new Ajax.Web.DataSet([]),
"TopDataValue": new Ajax.Web.DataSet([
new Ajax.Web.DataTable([
["HID","System.String"],
["HFrName0","System.String"],
["HFtName0","System.String"],
["HGFName0","System.String"],
["HFmName0","System.String"],
["TID","System.Byte"]
],[
["123456789","ABCD1","ABCD2","ABCD3 ","ABCD4",2]
])
]),
"DownDataValue": new Ajax.Web.DataSet([]),
"MenuDataValue": new Ajax.Web.DataSet([]),
"SearchReturnValue": new Ajax.Web.DataSet([]),
"Result": null,
"NewID": "NoID",
"AffectedRecords": 0
}
我使用这个代码:
var text= 'the json string here';
var obj=JSON.parse(text);
我认为问题在于JSON无法识别新的Ajax.Web.DataSet([])的类型
我该如何解决这个问题?
任何想法是赞赏。
非常感谢,
如果你真的把它放入你的代码中,你不需要引号,也不需要解析它:
var theObject = {
"__type": "HRIS.oHRData, HRIES, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"TPDDListValue": new Ajax.Web.DataSet([]),
"DPDDListValue": new Ajax.Web.DataSet([]),
"TopDataValue": new Ajax.Web.DataSet([
new Ajax.Web.DataTable([
["HID","System.String"],
["HFrName0","System.String"],
["HFtName0","System.String"],
["HGFName0","System.String"],
["HFmName0","System.String"],
["TID","System.Byte"]
],[
["123456789","ABCD1","ABCD2","ABCD3 ","ABCD4",2]
])
]),
"DownDataValue": new Ajax.Web.DataSet([]),
"MenuDataValue": new Ajax.Web.DataSet([]),
"SearchReturnValue": new Ajax.Web.DataSet([]),
"Result": null,
"NewID": "NoID",
"AffectedRecords": 0
};
这将要求无论什么服务都提供了Ajax
对象。
上一篇: Uncaught SyntaxError: Unexpected token e when try to parse a JSON string
下一篇: json error: SyntaxError: JSON.parse: unexpected character