gpt4 book ai didi

JSON 意外标记 chrome

转载 作者:行者123 更新时间:2023-12-02 22:31:48 24 4
gpt4 key购买 nike

我的浏览器 (chrome) 似乎不喜欢我的 JSON(通过 ASP.NET 的返回 Json(object) 格式化)。

我的 JavaScript 处理程序失败之处如下所示:

var responseObj = JSON.parse(msg);

在我解析它之前,我可以在 chrome JavaScript 调试器中看到所有内容,但是当我将它发送到 JSON.parse() 时它失败了。

真正奇怪的是 JSONLint 说它是有效的。

我的 JSON 看起来像这样(信不信由你,实际对象要长得多):

{
"crct": {
"ETL_ID": 221,
"DELETE_FLAG": "N",
"ID": "a0Wc00000008sZGEAY",
"ISDELETED": "false",
"NAMEX": "CRCT-4474",
"CREATEDDATE": "/Date(1345769442000)/",
"CREATEDBYID": "005C00000049nuYIAQ",
"LASTMODIFIEDDATE": "/Date(1345771729000)/",
"LASTMODIFIEDBYID": "005C00000049nuYIAQ",
"SYSTEMMODSTAMP": "/Date(1345771729000)/",
"CLIENT_TASK": "a0Xc0000001lLihEAE",
"COUNTRY": null,
"PRA_CRCT_ID": null,
"PROJECT_REGION": "a0mc00000008ZPgAAM",
"TOTAL_UNITS_FRM": 200,
"UNIT_SCOPE_CHANGE": null,
"UNIT_SCOPE_DIFFERENCE": 0,
"CUMULATIVE_OFFICIAL_FORECAST_U": 200,
"CUMULATIVE_PENDING_DOWNSCOPE_U": 0,
"CUMULATIVE_BASELINE_UNITS_ROLL": 200,
"CUMULATIVE_WORKED_HOURS_ROLLUP": 0,
"CUMULATIVE_WORKED_UNITS_ROLLUP": 0,
"CLIENT_UNIT_NUMBER": null,
"EntityState": 2,
"EntityKey": {
"EntitySetName": "SF_CLIENT_REGION_COUNTRY_TASK",
"EntityContainerName": "SFEntities",
"EntityKeyValues": [
{
"Key": "ETL_ID",
"Value": 221
}
],
"IsTemporary": false
}
},
"unitChecks": {
"gaps": false,
"duplicates": false,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(1370059200000)/",
"liDurations": [
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Baseline",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Previous Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Historical",
"gaps": false,
"duplicates": false
}
],
"numberOfUniqueBufCodes": 0
},
"effortChecks": {
"gaps": false,
"duplicates": false,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(1370059200000)/",
"liDurations": [
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Baseline",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Previous Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Historical",
"gaps": false,
"duplicates": false
}
],
"numberOfUniqueBufCodes": 0
},
"hourChecks": {
"gaps": false,
"duplicates": false,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(1370059200000)/",
"liDurations": [
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Baseline",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Previous Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Historical",
"gaps": false,
"duplicates": false
}
],
"numberOfUniqueBufCodes": 0
},
"effortRatioChecks": {
"gaps": false,
"duplicates": false,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(1370059200000)/",
"liDurations": [
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Baseline",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Previous Official Forecast",
"gaps": false,
"duplicates": false
},
{
"thisTypeFound": true,
"startDate": "/Date(1343793600000)/",
"endDate": "/Date(-62135578800000)/",
"type": "Historical",
"gaps": false,
"duplicates": false
}
],
"numberOfUniqueBufCodes": 0
}
}

最佳答案

JSON.parse 用于将 JSON 字符串解析为 JavaScript 对象。

如果您尝试解析一个对象(这是您在问题中发布的对象),您将在 Chrome 中收到“意外 token ”消息。

所以,要么你试图转换不需要转换的东西,要么你想把一个对象转换成 JSON,在这种情况下你需要 stringify

关于JSON 意外标记 chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12115523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com