从angularJS中的AJAX调用提取JSon数据
我想提取维护窗口列表,如angularJS中的startTime、endTime等。通过从angularJS中的AJAX调用提取JSon数据,angularjs,Angularjs,我想提取维护窗口列表,如angularJS中的startTime、endTime等。通过 您可以使用循环获取所有startTime,obj.appResponse.responseData.maintenanceWindowsres是您对ajax的响应 var stringify = '{ "appResponse": { "status": "Success", "description": "", "responseData": {
您可以使用循环获取所有
startTime
,obj.appResponse.responseData.maintenanceWindows
res
是您对ajax的响应
var stringify = '{
"appResponse": {
"status": "Success",
"description": "",
"responseData": {
"maintenanceWindows": [{
"maintenanceScheduleId": 1027438,
"sumInfoId": 5,
"startTime": null,
"duration": 8400,
"effectiveDate": 1522209600000,
"expiryDate": 1543554000000,
"timeZone": null,
"rowCreated": 1510179232000,
"rowLastUpdated": 1510179232000
}, {
"maintenanceScheduleId": 1027439,
"sumInfoId": 5,
"startTime": null,
"duration": 8400,
"effectiveDate": 1522209600000,
"expiryDate": 1543554000000,
"timeZone": null,
"rowCreated": 1510179232000,
"rowLastUpdated": 1510179232000
}, {
"maintenanceScheduleId": 1027440,
"sumInfoId": 5,
"startTime": null,
"duration": 8400,
"effectiveDate": 1522209600000,
"expiryDate": 1543554000000,
"timeZone": null,
"rowCreated": 1510179232000,
"rowLastUpdated": 1510179232000
}, {
"maintenanceScheduleId": 1027649,
"sumInfoId": 5,
"startTime": null,
"duration": 1800,
"effectiveDate": 1511326800000,
"expiryDate": 1511499600000,
"timeZone": null,
"rowCreated": 1511169722000,
"rowLastUpdated": 1511169722000
}, {
"maintenanceScheduleId": 1027638,
"sumInfoId": 5,
"startTime": null,
"duration": 12600,
"effectiveDate": 1511067600000,
"expiryDate": 1551416400000,
"timeZone": null,
"rowCreated": 1510827006000,
"rowLastUpdated": 1510827006000
}, {
"maintenanceScheduleId": 1027661,
"sumInfoId": 5,
"startTime": null,
"duration": 9000,
"effectiveDate": 1513659600000,
"expiryDate": 1513832400000,
"timeZone": null,
"rowCreated": 1511263590000,
"rowLastUpdated": 1511263590000
}]
}
}
}'
var obj = JSON.parse(stringify);
console.log(obj.appResponse.responseData.maintenanceWindows[0].startTime);
现在您可以使用maintenanceWindows获取数据了Ok。请提取数据。当您有更具体的问题或问题时,请返回(angular.min.js:123 SyntaxError:JSON中的意外标记o位于JSON.parse()的位置1)var obj=JSON.parse(stringify);
var stringify = '{
"appResponse": {
"status": "Success",
"description": "",
"responseData": {
"maintenanceWindows": [{
"maintenanceScheduleId": 1027438,
"sumInfoId": 5,
"startTime": null,
"duration": 8400,
"effectiveDate": 1522209600000,
"expiryDate": 1543554000000,
"timeZone": null,
"rowCreated": 1510179232000,
"rowLastUpdated": 1510179232000
}, {
"maintenanceScheduleId": 1027439,
"sumInfoId": 5,
"startTime": null,
"duration": 8400,
"effectiveDate": 1522209600000,
"expiryDate": 1543554000000,
"timeZone": null,
"rowCreated": 1510179232000,
"rowLastUpdated": 1510179232000
}, {
"maintenanceScheduleId": 1027440,
"sumInfoId": 5,
"startTime": null,
"duration": 8400,
"effectiveDate": 1522209600000,
"expiryDate": 1543554000000,
"timeZone": null,
"rowCreated": 1510179232000,
"rowLastUpdated": 1510179232000
}, {
"maintenanceScheduleId": 1027649,
"sumInfoId": 5,
"startTime": null,
"duration": 1800,
"effectiveDate": 1511326800000,
"expiryDate": 1511499600000,
"timeZone": null,
"rowCreated": 1511169722000,
"rowLastUpdated": 1511169722000
}, {
"maintenanceScheduleId": 1027638,
"sumInfoId": 5,
"startTime": null,
"duration": 12600,
"effectiveDate": 1511067600000,
"expiryDate": 1551416400000,
"timeZone": null,
"rowCreated": 1510827006000,
"rowLastUpdated": 1510827006000
}, {
"maintenanceScheduleId": 1027661,
"sumInfoId": 5,
"startTime": null,
"duration": 9000,
"effectiveDate": 1513659600000,
"expiryDate": 1513832400000,
"timeZone": null,
"rowCreated": 1511263590000,
"rowLastUpdated": 1511263590000
}]
}
}
}'
var obj = JSON.parse(stringify);
console.log(obj.appResponse.responseData.maintenanceWindows[0].startTime);
const myJson = res.JSON().appResponse;
const maintenanceWindows = myJson.responseData.maintenanceWindows