gpt4 book ai didi

javascript - 无法读取 JSON 字符串

转载 作者:行者123 更新时间:2023-12-02 19:11:00 24 4
gpt4 key购买 nike

我得到如下的 JSON 字符串

[
{
"id": 20,
"title": "a",
"allDay": true,
"start": "2012-12-04 00:00",
"end": "2012-12-07 00:00",
"color": "#eb491d",
"startDate": "/Date(1354559400000)/",
"endDate": "/Date(1354818600000)/",
"Location": "a",
"StartDatestr": "2012-12-04",
"EndDatestr": "2012-12-04",
"StartTime": "00:00",
"EndTime": "00:00",
"Alert": false,
"Repeat": false,
"RepeatDays": 0,
"CalendarID": 13,
"CustomerNo": 593963,
"CustomerName": "test_apple",
"IsProspect": true,
"Description": ""
}
]

当我检查如下长度时,它返回“1”

console.log(myAppointment.length);

但是当我尝试如下访问时,它会给出未定义的错误。

var myAppointment = JSON.parse(data.d);
sessionStorage.CustomerID = data.CustomerNo;
console.log(sessionStorage.CustomerID);

我不知道。谁能告诉我我在这里缺少什么

最佳答案

将解析代码更改为:

var myAppointment = JSON.parse(data.d)[0];

关于javascript - 无法读取 JSON 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13716972/

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