从 node-red 中的 JSON 获取数据

Getting data out of JSON in node-red

我一直在努力从一个 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"
    }
}

我想获取 "temperature" 之后的数据,例如。 例如 Tairneuf。

return {payload:msg.payload.temperature.Tairneuf};

出现错误:

TypeError: Cannot read property 'Tairneuf' of undefined

感谢所有愿意提供帮助的人!

您忘记了中间密钥:"data":

msg.payload.data.temperature.Tairneuf