【发布时间】:2021-03-06 10:17:51
【问题描述】:
我有一个无法从中获取特定值的天气预报 JSON 对象。我正在尝试从下面的 json 中获取 weather_description。
JSON
{
"request": {
"type": "City",
"query": "New York",
"language": "en",
"unit": "m"
},
"location": {
"name": "New York",
"country": "United States of America",
"region": "New York",
"lat": "40.714",
"lon": "-74.006",
"timezone_id": "America/New_York",
"localtime": "2020-11-23 10:30",
"localtime_epoch": 1606127400,
"utc_offset": "-5.0"
},
"current": {
"observation_time": "03:30 PM",
"temperature": 11,
"weather_code": 122,
"weather_icons": [
"https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"
],
"weather_descriptions": [
"Overcast"
],
"wind_speed": 19,
"wind_degree": 340,
"wind_dir": "NNW",
"pressure": 1014,
"precip": 12,
"humidity": 77,
"cloudcover": 100,
"feelslike": 8,
"uv_index": 3,
"visibility": 16,
"is_day": "yes"
}
}
HTML
<div>{{this.weatherData | keyvalue }}</div>
TS 文件
getWeatherReport(data){
this.weatherService.getWeatherReport(data.location).subscribe(
data => {this.weatherData = data; });
预期输出: 阴
实际输出: [对象对象],[对象对象],[对象对象]
【问题讨论】:
标签: html json angular typescript output