从angularJS中的AJAX调用中提取JSon数据

时间:2017-11-27 12:58:28

标签: angularjs

{"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}]}}}

我想在angularJS中提取维护窗口列表,例如startTime,endTime等。

2 个答案:

答案 0 :(得分:0)

通过angular.fromJson

将此字符串反序列化为对象

答案 1 :(得分:0)

res是您对ajax的回复

const myJson = res.JSON().appResponse;
const maintenanceWindows = myJson.responseData.maintenanceWindows

现在您可以使用maintenanceWindows

获取数据