I've never used JavaScript before and I'm stumped about how to access a particular value in an Object.
The JSON looks like this:
{
"payload":{
"params":{
"switch:0":{
"output":false, **<= trying to get this value ("false")**
}
}
},
}
Node-Red, the tool I'm working with, represents the object like this in its debug pane:
I assumed this was an array and could be accessed like so:
value = msg.payload.params.switch[0].output
But I get an error:
"TypeError: Cannot read property '0' of undefined"
If I try:
value = msg.payload.params.switch
the value is reported as "undefined".
What is the correct way in JavaScript to access the value of "output"? I googled a bunch trying to find an answer, but have been unsuccessful.
Any help is appreciated!