从jQuery whatweather获取描述

Getting description from jQuery whatweather

本文关键字:描述 获取 whatweather jQuery      更新时间:2024-05-09

我已经安装了jQuery插件WhatWeather,它运行良好,但有一个小问题。

当我得到天气数据时,我得到了这个txt文件。

{ "data": { "current_condition": [ {"cloudcover": "100", "humidity": "100", "localObsDateTime": "2013-12-08 02:23 PM", "observation_time": "01:23 PM", "precipMM": "4.3", "pressure": "1008", "temp_C": "7", "temp_F": "45", "visibility": "7", "weatherCode": "296",  "weatherDesc": [ {"value": "Light rain" } .....] }}

为了获得页面上显示的数据,我使用"currentCondition.cloudcover",然后得到cloudcover 100,但我无法获得天气描述,我尝试了"currentCondition.wweatherDesc",然后我得到了输出"Object:Object"。而不是"小雨"如何从txt文件中获得值"小雨"?

wheatherDesc是对象本身的数组,因此请尝试currentCondition.weatherDesc[0].value

总体而言:

data.current_condition[0].weatherDesc[0].value