I’m getting a JSON string as below
[
{
"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": ""
}
]
When I check the length as below it returns “1”
console.log(myAppointment.length);
But when I try to access as below it gives Undefined error.
var myAppointment = JSON.parse(data.d);
sessionStorage.CustomerID = data.CustomerNo;
console.log(sessionStorage.CustomerID);
I have no idea. Can anyone please tell me what I’m missing here
Change your parsing code to: