我一直在努力从我从节点中获取的JSON http请求中获取数据。 我发现的其他解决方案似乎是针对JSON数据而不是那么复杂(无论如何......)
这是JSON数据:
{
"config": {
"ventilateurs": {
"admission": {
"absent": 15,
"actuel": 70,
"vitesse1": 35,
"vitesse2": 50,
"vitesse3": 70
},
"extraction": {
"absent": 15,
"actuel": 70,
"vitesse1": 35,
"vitesse2": 50,
"vitesse3": 70
},
"extractionetat": 1,
"vitesse": 4
}
},
"data": {
"bypass": {
"correction": 5,
"facteur": 5,
"mode": "hiver",
"periode": 0
},
"etatswitches": {
"L1": "ON",
"L2": "OFF",
"SDB": "OFF",
"SDBluxe": "OFF",
"hotte": "OFF"
},
"temperature": {
"Tairneuf": 8.5,
"Tconfort": 23.0,
"Textrait": 11.0,
"Trepris": 19.0,
"Tsoufflage": 20.0,
"capteur": {
"TEnthalpie": "absent",
"Tairneuf": "present",
"Tappoint": 0.0,
"Tapppoint": "absent",
"Tenthaplie": 0.0,
"Textrait": "present",
"Thotte": 0.0,
"Trepris": "present",
"Tsoufflage": "present"
}
},
"usage": {
"absent": 0,
"antigel": 0,
"bypass": 7005,
"filtres": 2928,
"prechauffe": 43,
"vitesse1": 11791,
"vitesse2": 5814,
"vitesse3": 62
},
"valvesetat": {
"bypass": 0,
"courantmoteurbypass": 0,
"courantmoteurprechauf": 0,
"prechauff": 0
},
"ventilateurs": {
"extraitpourcent": 70,
"extraitrpm": 2029,
"soufflagepourcent": 70,
"soufflagerpm": 2165
}
},
"device": {
"firmware": "3.30",
"name": "CA350 luxe"
}
}
我希望得到“温度”之后的数据。 以Tairneuf为例。
return {payload:msg.payload.temperature.Tairneuf};
出错:
TypeError: Cannot read property 'Tairneuf' of undefined
对任何愿意帮忙的人都已经过了!
答案 0 :(得分:0)
您忘记了中间密钥:“数据”:
msg.payload.data.temperature.Tairneuf