2017-06-06 103 views
1
[ 
    { 
    "docId": "58d8f38cd2f554fdfca4fd18", 
    "__v": 8, 
    "clinicDetails": { 
     "5908e342236dee7e7364698e": { 
     "appointmentSlots": { 
      "sat": { 
      "5908e342236dee7e73646a44": { 
       "bookFlag": true, 
       "endTime": "07:00PM", 
       "startTime": "06:30PM" 
      }, 
      "5908e342236dee7e73646a43": { 
       "bookFlag": true, 
       "endTime": "06:30PM", 
       "startTime": "06:00PM" 
      }, 
....... 

完整的文件: https://docs.google.com/document/d/1FK1NEY1Vmjzv2gBtleFquA0VMpfYGf9FaMyblPr8vws/edit?usp=sharing从JSON获取关键的API请求

我需要访问这些预约时段的ID,如5908e342236dee7e73646a44,这样我就可以在API request

我把它使用角度。

回答

1

尝试使用

var jsonObject = angular.fromJson(yourJsonString)

,将改变您的JSON的对象。然后,您可以迭代对象的任何字段并获取键或值。

angular.forEach(jsonObject.whatever, function(value, key) { 
    console.log('key : ', key); 
    console.log('value : ', value); 
}); 
+0

感谢队友那工作 –