I am using node red 3.0.3 and node js v18.16.0 in a raspberry pi. A flow storage (gravity sensor) in my program is generating an object with many fields. I want to know how can I get one of the fields ,this field should be number, so I guess that the field should be converted to a integer. How can I do that?
This is the object structure (in fact has more fields), the only field that I need is called "minor"
Ok, not impossible.
But you need to post the data better.
Where you posted the message:
Before pasting the code, click the
</> button at the top (Or Control e)
type or paste code here
And paste the code/message where it says.
I'm guessing the part you want is
msg.minor, but can not be sure.
function node after the node that gives you the above message and basically you make it:
const msg.payload = parseInt(msg.minor);
Then the next node gets a payload with an integer value which is what
msg.minor was in the previous message.
According to you image minor is already a number (shows blue in debug) If you hover your mouse over the minor name you will see three icons. One is copy path, If you copy it and paste it in a change node you can move the value where ever you wish.
In a change node to move it to msg.payload
to value of
You may get some benefit from watching the
Thanks a lot, it worked
var res = Number(str);
msg.payload = res;
In case you did not realise, you can shorten that to
msg.payload = Number(str)*1000
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.