-2

我想在 Angularjs 中访问以下 JSON 的每个数据值。但我找不到办法。假设我想访问以下查询的类型、名称、大小、单位。那么如何访问它,有人可以帮我解决这个问题吗?

{
"**openEHR-EHR-OBSERVATION.body_temperature.v1/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value**":{

"type": "DV_QUANTITY",

"name": "Temperature",

"serie":[
{
"magnitude": 34,

"units": "°C",

"date": "2016-12-28 13:23:32"

}

]
},
4

3 回答 3

2

你可以用 ng-repeat 做这样的事情

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.name = {
"openEHR-EHR-OBSERVATION.body_temperature.v1/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value":{
"type": "DV_QUANTITY",
"name": "Temperature",
"serie":[
{
"magnitude": 34,
"units": "°C",
"date": "2016-12-28 13:23:32"
},
{
"magnitude": 34,
"units": "°C",
"date": "2016-12-29 06:49:51"
},
{
"magnitude": 38,
"units": "°C",
"date": "2016-12-29 06:49:51"
}
]
},
"openEHR-EHR-OBSERVATION.blood_pressure.v1/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value":{
"type": "DV_QUANTITY",
"name": "Systolic",
"serie":[
{
"magnitude": 4,
"units": "mm[Hg]",
"date": "2016-12-28 13:23:32"
},
{
"magnitude": 9,
"units": "mm[Hg]",
"date": "2016-12-29 06:49:51"
},
{
"magnitude": 7,
"units": "mm[Hg]",
"date": "2016-12-29 06:49:51"
}
]
},
"openEHR-EHR-OBSERVATION.blood_pressure.v1/data[at0001]/events[at0006]/data[at0003]/items[at0005]/value":{
"type": "DV_QUANTITY",
"name": "Diastolic",
"serie":[
{
"magnitude": 6,
"units": "mm[Hg]",
"date": "2016-12-28 13:23:32"
},
{
"magnitude": 17,
"units": "mm[Hg]",
"date": "2016-12-29 06:49:51"
},
{
"magnitude": 12,
"units": "mm[Hg]",
"date": "2016-12-29 06:49:51"
}
]
},
"openEHR-EHR-OBSERVATION.pulse.v1/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value":{
"type": "DV_QUANTITY",
"name": "Rate",
"serie":[
{
"magnitude": 6,
"units": "/min",
"date": "2016-12-28 13:23:32"
},
{
"magnitude": 17,
"units": "/min",
"date": "2016-12-29 06:49:51"
},
{
"magnitude": 15,
"units": "/min",
"date": "2016-12-29 06:49:51"
}
]
},
"openEHR-EHR-OBSERVATION.pulse.v1/data[at0002]/events[at0003]/data[at0001]/items[at0005]/value":{
"type": "DV_CODED_TEXT",
"name": "Regular?",
"serie":[
{
"code": "at0006at1028",
"value": "Regular",
"date": "2016-12-28 13:23:32"
},
{
"code": "at0006at1028",
"value": "Irregular",
"date": "2016-12-29 06:49:51"
},
{
"code": "at0006at1028",
"value": "Irregular",
"date": "2016-12-29 06:49:51"
}
]
},
"openEHR-EHR-OBSERVATION.respiration.v1/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value":{
"type": "DV_QUANTITY",
"name": "Rate",
"serie":[
{
"magnitude": 5,
"units": "/min",
"date": "2016-12-28 13:23:32"
},
{
"magnitude": 9,
"units": "/min",
"date": "2016-12-29 06:49:51"
},
{
"magnitude": 13,
"units": "/min",
"date": "2016-12-29 06:49:51"
}
]
},
"openEHR-EHR-OBSERVATION.respiration.v1/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value":{
"type": "DV_CODED_TEXT",
"name": "Rhythm",
"serie":[
{
"code": "at0006at0007",
"value": "Regular",
"date": "2016-12-28 13:23:32"
},
{
"code": "at0006at0007",
"value": "Regular",
"date": "2016-12-29 06:49:51"
}
]
}
    
  }

});
<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <link rel="stylesheet" href="style.css" />
    <script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script>
    <script src="app.js"></script>
  </head>

  <body ng-controller="MainCtrl">
<div ng-repeat="(k,v) in name">
<p>{{v.type}}</p>
<p>{{v.name}}</p>
<span ng-repeat="x in v.serie">
   magnitude: {{x.magnitude}},
   units:{{x.units}},
   date:{{x.date}}<br>
</span>
</div>
    </body>

</html>

于 2016-12-29T06:14:43.107 回答
1

工作演示:

var myApp = angular.module('myApp',[]);

myApp.controller('MyCtrl', function($scope) {
  $scope.jsonObj = {
	    "openEHR": {
		     "type": "DV_QUANTITY",
		     "name": "Temperature",
		     "serie": [{
				    "magnitude": 34,
				    "units": "°C",
				    "date": "2016-12-28 13:23:32"
			   }]
	    }
   }
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
  Type : {{jsonObj.openEHR.type}}<br>
  Name : {{jsonObj.openEHR.name}}<br>
  <div ng-repeat="item in jsonObj.openEHR.serie">
     Magnitude : {{item.magnitude}}
  </div>
</div>

于 2016-12-29T07:48:34.970 回答
0

这似乎是来自 EHRServer 的查询结果。

“serie”对象始终是符合“type”的对象数组,因此您需要首先检查类型,以了解“serie”对象中预期的字段。

对于 type = DV_QUANTITY,您将始终获得“幅度”和“单位”。当您“按路径分组”时,“日期”将始终存在。

您可以在官方文档中找到更多信息https://cloudehrserver.com/learn

顺便说一句,我是 EHRServer 的创建者。如果您对此有任何疑问,我们有一个社区支持聊天https://gitter.im/CaboLabs/EHRServer

于 2020-06-17T17:35:59.740 回答