Uncaught SyntaxError: Unexpected token e when try to parse a JSON string
I try to use JSON.parse to return a javascript object of the string below. However, I receive "Uncaught SyntaxError: Unexpected token 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
}
I use this code:
var text= 'the json string here';
var obj=JSON.parse(text);
I think the issue is that JSON doesn't recognize the type of new Ajax.Web.DataSet([])
How can I solve this issue, please?
Any idea is appreciated.
Many thanks,
If you're really just dropping that into your code, you don't need quotes and you don't need to parse it:
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
};
This will require that whatever service provides that Ajax
object exists.
上一篇: json.parse意外令牌错误