Getting a value from a json property with space in the name

Hi, Guys!

I'm receiving the JSON string below and converting it to a JavaScript Object.

{"electricFaultStamp":{"id":"Timed overcurrent relay fault","Ansi Code":51,"Flag":1,"Lock":0,"Time Stamp":"Thu Jan 1 00:16:10 1970"}}

Then, I'm using a function node to try to get and use the Time Stamp value using the code below:

var time = msg.payload.electricFaultStamp.Time Stamp; // I also tried (Time_Stamp)
msg.payload= time;
return msg;

but I was not able to get this value... Is it allowed to have a property name with space in the middle of the name in a Javascript object?

Take a look in the forums, something similar was just answered a short time ago.

1 Like

Tks... I've just found it on stackflow. I used:

var time = msg.payload.electricFaultStamp['Time Stamp'];

You can just grab the path from debug...

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.