版本
我想从当地的官方气象站检索一些天气观测资料。我可以选择csv& JSON
它返回这个嵌套数组:
对象
我只想要 data:数组,所以我使用了一个函数节点" Extract Value"使用此代码:
msg.payload = msg.payload.observations.data[0]
return msg;
上面的函数返回了这个对象:
如果我通过存储节点将其放入InfluxDB,我收到此错误:
错误:发生400错误请求错误:{"错误":"无法解析&bom-obs-moorabbin-airport aifstime_utc = \" 20170513070000 \& #34;,air_temp = 13.6,apparent_t = 10.6,浊= \" - \",cloud_base_m = NULL,cloud_oktas = NULL,cloud_type = \" - \",cloud_type_id =空,delta_t = 2.9,dewpt = 7.6,gust_kmh = 17,gust_kt = 9,history_product = \" IDV60801 \",LAT = -38,LOCAL_DATE_TIME = \" 13/05:00 \ ",local_date_time_full = \" 20170513170000 \",lon = 145.1,name = \" Moorabbin Airport \",press = 1023.5,press_msl = 1023.5,press_qnh = 1023.5, press_tend = \" - \",rain_trace = \" 0.0 \",rel_hum = 67,sea_state = \" - \",排序顺序= 0, swell_dir_worded = \" - \",swell_height = NULL,swell_period = NULL,vis_km = \" 10 \",天气= \" - \&#34 ;, wind_dir = \" SSW \",wind_spd_kmh = 13,wind_spd_kt = 7,wmo = 94870':无效号码"}
相反,如果我在" Extract Value"之间插入一个JSON节点。 &安培; InfluxDB存储节点,这是我得到的调试输出:
" {" sort_order":0," wmo":94870," name":" Moorabbin Airport",& #34; history_product":" IDV60801"" LOCAL_DATE_TIME":" 13/05:00 pm"," local_date_time_full":&# 34; 20170513170000"" aifstime_utc":" 20170513070000"" LAT": - 38" LON":145.1&# 34; apparent_t":10.6,"云":" - "" cloud_base_m":空," cloud_oktas":空, " cloud_type":" - "" cloud_type_id":空," delta_t":2.9," gust_kmh&#34 ;: 17," gust_kt":9," air_temp":13.6," dewpt":7.6,"按":1023.5," press_msl":1023.5," press_qnh":1023.5," press_tend":" - "" rain_trace":" 0.0"" rel_hum":67," sea_state":" - "" swell_dir_worded":" - "" swell_height":空," swell_period":空," vis_km":" 10""天气和#34;:" - "" wind_dir":" SSW""瓦特ind_spd_kmh":13," wind_spd_kt":7}"
当我将该JSON节点附加到InfluxDB存储节点时,没有抛出任何错误,但在InfluxDB中没有我可以在Grafana中查看,绘图或制表的值。
从该网站获取上述Feed并将其导入InfluxDB的最佳方法是什么,以便我可以在Grafana中以图形方式查看它?
答案 0 :(得分:0)
你可以试试这个:
return {
payload: {
data : msg.payload.observations.data[0]
}
};