gpt4 book ai didi

html - 在 Angular 6 模板中解析 Json 数据

转载 作者:行者123 更新时间:2023-11-27 23:49:16 24 4
gpt4 key购买 nike

我收到如下 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]));

})
}

但我没有在我的模板中获取价格值。我也尝试使用 map

this.allPrice=data['Realtime Stock pric'].map(d=>d.price); 

但这也行不通。

我能做什么?请建议

最佳答案

应该是

this.allPrice=data['Realtime Stock price']; 

不是

this.allPrice=data['Realtime Stock pric'];

关于html - 在 Angular 6 模板中解析 Json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56629868/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com