I'm struggling with accessing a specific value in an Object in JavaScript for the first time.
The JSON I'm working with is structured like this:
{
"payload":{
"params":{
"switch:0":{
"output":false, **<= I need to retrieve this value ("false")**
}
}
},
}
When I look at the object in Node-Red's debug pane, it appears like this:
https://i.sstatic.net/x7pVW.png
I initially thought it was an array and tried accessing it like this:
value = msg.payload.params.switch[0].output
Unfortunately, I received an error message:
"TypeError: Cannot read property '0' of undefined"
I also attempted:
value = msg.payload.params.switch
but the value returned was "undefined".
Can someone guide me on the correct way to access the value of "output" in JavaScript? I've tried searching online for answers, but haven't had any luck.
Any assistance would be greatly appreciated!