JSON 来自烧瓶

JSON from flask

我正在尝试从 url 中获取数据,而不是我用 angularjs 和 restangular 生成的烧瓶。 我有这个 json 数据:

{"patients": ["{\"_id\": {\"$oid\": \"5677d634cc18e44063fa3556\"}, \"id_patient\": \"2015120001\", \"last_name\": \"Chiacchiaretta\", \"first_name\": \"Piero\", \"gender\": \"M\", \"birthdate\": {\"$date\": 307238400000}, \"birthplace\": \"PESCARA\", \"codice_fiscale\": \"CHCPRI79P27G482U\", \"address\": \"Via Aldo Moro, 114\", \"city\": \"SAN GIOVANNI TEATINO\", \"province\": \"CH\", \"cap\": \"66020\", \"phone_number\": \"3294946261\", \"email\": \"piero.chiacchiaretta@gmail.com\", \"age\": 36, \"nationality\": \"italiana\", \"status\": \"Attivo\"}", "{\"_id\": {\"$oid\": \"5677d634cc18e44063fa3557\"}, \"id_patient\": \"2015120002\", \"last_name\": \"Guidotti\", \"first_name\": \"Andrea\", \"gender\": \"M\", \"birthdate\": {\"$date\": 418568880000}, \"birthplace\": \"AGRIGENTO\", \"codice_fiscale\": \"GDTNDR83D07A089P\", \"address\": \"Via della Liberazione 55\", \"city\": \"SAN BENEDETTO DEL TRONTO\", \"province\": \"AP\", \"cap\": \"63074\", \"phone_number\": \"3404751719\", \"email\": \"rob.guidotti@gmail.com\", \"age\": 32, \"nationality\": \"italiana\", \"status\": \"Revocato\", \"status_note\": \"Problemi con il medico curante!\"}"]}

我不知道这是什么意思... 我能够获得完整的对象,但我无法访问单个 value/fields... 有什么建议吗?

这里是解码响应的方法,响应是一个包含只有一项的数组的对象。

function ctrl($scope){
  var data = {
 "patients" : ["{\"_id\": {\"$oid\": \"5677d634cc18e44063fa3556\"}, \"id_patient\": \"2015120001\", \"last_name\": \"Chiacchiaretta\", \"first_name\": \"Piero\", \"gender\": \"M\", \"birthdate\": {\"$date\": 307238400000}, \"birthplace\": \"PESCARA\", \"codice_fiscale\": \"CHCPRI79P27G482U\", \"address\": \"Via Aldo Moro, 114\", \"city\": \"SAN GIOVANNI TEATINO\", \"province\": \"CH\", \"cap\": \"66020\", \"phone_number\": \"3294946261\", \"email\": \"piero.chiacchiaretta@gmail.com\", \"age\": 36, \"nationality\": \"italiana\", \"status\": \"Attivo\"}", "{\"_id\": {\"$oid\": \"5677d634cc18e44063fa3557\"}, \"id_patient\": \"2015120002\", \"last_name\": \"Guidotti\", \"first_name\": \"Andrea\", \"gender\": \"M\", \"birthdate\": {\"$date\": 418568880000}, \"birthplace\": \"AGRIGENTO\", \"codice_fiscale\": \"GDTNDR83D07A089P\", \"address\": \"Via della Liberazione 55\", \"city\": \"SAN BENEDETTO DEL TRONTO\", \"province\": \"AP\", \"cap\": \"63074\", \"phone_number\": \"3404751719\", \"email\": \"rob.guidotti@gmail.com\", \"age\": 32, \"nationality\": \"italiana\", \"status\": \"Revocato\", \"status_note\": \"Problemi con il medico curante!\"}"]
     };
     $scope.patient = angular.fromJson(data.patients[0]);
}
<html ng-app>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>
<body ng-controller="ctrl">
  <pre>patient.codice_fiscale = {{patient.codice_fiscale | json}}</pre>
  <pre>patient = {{patient | json}}</pre>
</body>
</html>

执行代码片段,您可以看到如何访问患者的 "codice_fiscale" 字段。