Payload object with "-" in the name does not work

Hi all,

when i retrive the wps status from a Fritz!Box i get the payload:

{"NewX_AVM-DE_WPSMode":"stop","NewX_AVM-DE_WPSStatus":"err_timeout"}

to display the values i have split node:

var Mode = {payload: msg.payload.NewX_AVM-DE_WPSMode};
var Status = {payload: msg.payload.NewX_AVM-DE_WPSStatus};

return [Mode,Status];

here comes the error:

ReferenceError: DE_WPSMode is not defined (line 1, col 43)

the first part of the payload object is not read. Is there a option to rename the part of payload object or how to get the right value?

Thanks to all
Hubertus

When JavaScript sees msg.payload.NewX_AVM-DE_WPSMode it interprets it as:

msg.payload.NewX_AVM - DE_WPSMode

In other words, it tries to subtract the value of the variable DE_WPSMode from msg.payload.NewX_AVM, but as DE_WPSMode doesn't exist, you get the error you see.

To access that object property, you'll have to use the alternative syntax:

msg.payload["NewX_AVM-DE_WPSMode"]

Hi knolleary,

thank you for the fast answer!
it works! perfekt.