html - 在 Angular 6 模板中解析 Json 数据
问题描述
我收到如下 JSON 响应,
{
"Meta Data" : {
"ticker" : "NEE",
"datapoints" : 320,
"credit cost" : 320,
"Time Zone" : "America/New_York",
"last refreshed" : "06/17/2019 at 09:27AM ET"
},
"Realtime Stock price" : [ {
"ticker" : "NEE",
"date" : "20190614",
"minute" : "15:58:01",
"volume" : 1028861,
"price" : 207.02,
"timezone" : "EDT",
"timezone_name" : "America/New_York",
"gmt_offset" : -14400
}, {
"ticker" : "NEE",
"date" : "20190614",
"minute" : "15:57:00",
"volume" : 996057,
"price" : 207.14,
"timezone" : "EDT",
"timezone_name" : "America/New_York",
"gmt_offset" : -14400
}]}
这是我的代码,
allPrice: Array<object> = [];
getShareData(){
this.dataservice.getSharePrice().subscribe(data=>{
this.allPrice=data['Realtime Stock pric'];
console.log("Show Price"+JSON.stringify(this.allPrice[1]));
})
}
但我没有在我的模板中获得价格价值。我也骑着地图
this.allPrice=data['Realtime Stock pric'].map(d=>d.price);
但这也行不通。
我能做些什么 ?请建议
解决方案
它应该是
this.allPrice=data['Realtime Stock price'];
不是
this.allPrice=data['Realtime Stock pric'];
推荐阅读
- python - 使用 `keras.utils.Sequence` 作为输入时,不支持 `y` 参数。错误
- oracle - ORA-00936: 缺少表达式
- javascript - 如何使特定选项出现在选择菜单中?
- r - 使用 model.matrix 的 One-hot 编码
- bash - 重新分发文件夹中的文件
- c++ - C ++中struct后双括号的含义?
- ssl - Windows 上的 Composer 安装程序错误:OpenSSL 因“证书验证失败”错误而失败
- ceph - cephfs 出现“只读文件系统”错误,如何处理?
- python - IndentationError: unindent 不匹配任何外部缩进
- amazon-web-services - 如何让 Terraform 等待 cloudinit 完成?