Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

407
Views
Node-Red: Parse JavaScript Object with Double value

I am using node-RED to call in data from a robot. In the debug window it says it is a 'msg: Object', and when I copy it to a notepad it takes the format: {"topic":"","payload":27.659992218017578,"_session":{"type":"tcp","id":"0151ff7339437ec6"},"_msgid":"6a6897605a523366"}

I am also not sure if this is a JSON object or not, as I see examples with '' around the brackets.

I am trying to use the function node within node-red to parse this to attain the "payload" value. However, it keeps returning as undefined.

I am using the script:

var json =msg.payload;
var obj = JSON.parse(json);
msg.payload = console.log(obj.payload);
return msg;

I am a beginner to javascript and JSON, however I have tried searching and all examples only have integers as the parsing value. I am also unsure if the value name itself 'payload' is causing an issue. I have also attempted to stringify and using 'getDouble' but had no luck, which I owe to my lack of experience.

I appreciate any guidance.

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

You don't need to do anything. The value of msg.payload is already a double.

Without a lot more context of what you are trying to do there isn't anything else that we can say here.

about 4 years ago · Santiago Gelvez Report

0

After the node that gets the above information (the data in {} in the question}, I then added the 'json' node, and then used the debug node with msg.payload as the output. This output the payload value above as a string. I have now been able to add a function node that allows me to edit the data as needed.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!